From ad54d22cf38dac33ee321ca235b42fb8b1c8661f Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 27 Jun 2022 02:36:00 +0000 Subject: [PATCH] CodeGen from PR 19600 in Azure/azure-rest-api-specs Merge 4276d9fd4a12fea33afa5b8905b69f5675eec5ac into 182d92fc16cc51247ffd4e863dee28c77c6484d2 --- sdk/compute/azure-mgmt-compute/_meta.json | 6 +- .../compute/_compute_management_client.py | 31 +- .../compute/aio/_compute_management_client.py | 31 +- .../azure/mgmt/compute/models.py | 2 +- .../mgmt/compute/v2015_06_15/__init__.py | 13 +- .../v2015_06_15/_compute_management_client.py | 36 +- .../mgmt/compute/v2015_06_15/_version.py | 2 +- .../mgmt/compute/v2015_06_15/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 36 +- .../v2015_06_15/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 122 +- .../v2015_06_15/aio/operations/_patch.py | 19 + .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 187 +- .../_virtual_machine_images_operations.py | 114 +- ...irtual_machine_scale_set_vms_operations.py | 330 ++- .../_virtual_machine_scale_sets_operations.py | 547 ++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 470 ++-- .../compute/v2015_06_15/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 19 +- .../compute/v2015_06_15/models/_models_py3.py | 299 ++- .../mgmt/compute/v2015_06_15/models/_patch.py | 19 + .../v2015_06_15/operations/__init__.py | 5 + .../_availability_sets_operations.py | 216 +- .../compute/v2015_06_15/operations/_patch.py | 19 + .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 272 +- .../_virtual_machine_images_operations.py | 207 +- ...irtual_machine_scale_set_vms_operations.py | 491 ++-- .../_virtual_machine_scale_sets_operations.py | 830 +++--- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 708 ++++-- .../mgmt/compute/v2016_03_30/__init__.py | 13 +- .../v2016_03_30/_compute_management_client.py | 36 +- .../mgmt/compute/v2016_03_30/_version.py | 2 +- .../mgmt/compute/v2016_03_30/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 36 +- .../v2016_03_30/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 141 +- .../v2016_03_30/aio/operations/_patch.py | 19 + .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 187 +- .../_virtual_machine_images_operations.py | 114 +- ...irtual_machine_scale_set_vms_operations.py | 330 ++- .../_virtual_machine_scale_sets_operations.py | 547 ++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 487 ++-- .../compute/v2016_03_30/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 19 +- .../compute/v2016_03_30/models/_models_py3.py | 309 ++- .../mgmt/compute/v2016_03_30/models/_patch.py | 19 + .../v2016_03_30/operations/__init__.py | 5 + .../_availability_sets_operations.py | 254 +- .../compute/v2016_03_30/operations/_patch.py | 19 + .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 272 +- .../_virtual_machine_images_operations.py | 207 +- ...irtual_machine_scale_set_vms_operations.py | 491 ++-- .../_virtual_machine_scale_sets_operations.py | 830 +++--- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 744 +++--- .../compute/v2016_04_30_preview/__init__.py | 13 +- .../_compute_management_client.py | 48 +- .../compute/v2016_04_30_preview/_version.py | 2 +- .../v2016_04_30_preview/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 48 +- .../aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 141 +- .../aio/operations/_disks_operations.py | 315 ++- .../aio/operations/_images_operations.py | 176 +- .../aio/operations/_patch.py | 19 + .../aio/operations/_snapshots_operations.py | 315 ++- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 187 +- .../_virtual_machine_images_operations.py | 114 +- ...irtual_machine_scale_set_vms_operations.py | 371 ++- .../_virtual_machine_scale_sets_operations.py | 588 +++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 528 ++-- .../v2016_04_30_preview/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 27 +- .../v2016_04_30_preview/models/_models_py3.py | 546 ++-- .../v2016_04_30_preview/models/_patch.py | 19 + .../operations/__init__.py | 5 + .../_availability_sets_operations.py | 252 +- .../operations/_disks_operations.py | 472 ++-- .../operations/_images_operations.py | 272 +- .../v2016_04_30_preview/operations/_patch.py | 19 + .../operations/_snapshots_operations.py | 472 ++-- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 272 +- .../_virtual_machine_images_operations.py | 207 +- ...irtual_machine_scale_set_vms_operations.py | 549 ++-- .../_virtual_machine_scale_sets_operations.py | 888 ++++--- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 802 +++--- .../mgmt/compute/v2017_03_30/__init__.py | 13 +- .../v2017_03_30/_compute_management_client.py | 64 +- .../mgmt/compute/v2017_03_30/_version.py | 2 +- .../mgmt/compute/v2017_03_30/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 64 +- .../v2017_03_30/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 141 +- .../aio/operations/_disks_operations.py | 315 ++- .../aio/operations/_images_operations.py | 176 +- .../v2017_03_30/aio/operations/_patch.py | 19 + .../operations/_resource_skus_operations.py | 48 +- .../aio/operations/_snapshots_operations.py | 315 ++- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 187 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 65 +- ...machine_scale_set_extensions_operations.py | 157 +- ...e_scale_set_rolling_upgrades_operations.py | 130 +- ...irtual_machine_scale_set_vms_operations.py | 371 ++- .../_virtual_machine_scale_sets_operations.py | 653 +++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 652 +++-- .../compute/v2017_03_30/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 39 +- .../compute/v2017_03_30/models/_models_py3.py | 639 +++-- .../mgmt/compute/v2017_03_30/models/_patch.py | 19 + .../v2017_03_30/operations/__init__.py | 5 + .../_availability_sets_operations.py | 254 +- .../operations/_disks_operations.py | 472 ++-- .../operations/_images_operations.py | 272 +- .../compute/v2017_03_30/operations/_patch.py | 19 + .../operations/_resource_skus_operations.py | 67 +- .../operations/_snapshots_operations.py | 472 ++-- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 272 +- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 101 +- ...machine_scale_set_extensions_operations.py | 236 +- ...e_scale_set_rolling_upgrades_operations.py | 183 +- ...irtual_machine_scale_set_vms_operations.py | 549 ++-- .../_virtual_machine_scale_sets_operations.py | 988 +++++--- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 1000 +++++--- .../mgmt/compute/v2017_09_01/__init__.py | 13 +- .../v2017_09_01/_compute_management_client.py | 4 +- .../mgmt/compute/v2017_09_01/_version.py | 2 +- .../mgmt/compute/v2017_09_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 4 +- .../v2017_09_01/aio/operations/__init__.py | 5 + .../v2017_09_01/aio/operations/_patch.py | 19 + .../operations/_resource_skus_operations.py | 48 +- .../compute/v2017_09_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 7 +- .../compute/v2017_09_01/models/_models_py3.py | 14 +- .../mgmt/compute/v2017_09_01/models/_patch.py | 19 + .../v2017_09_01/operations/__init__.py | 5 + .../compute/v2017_09_01/operations/_patch.py | 19 + .../operations/_resource_skus_operations.py | 67 +- .../mgmt/compute/v2017_12_01/__init__.py | 13 +- .../v2017_12_01/_compute_management_client.py | 60 +- .../mgmt/compute/v2017_12_01/_version.py | 2 +- .../mgmt/compute/v2017_12_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 60 +- .../v2017_12_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 162 +- .../aio/operations/_images_operations.py | 225 +- .../operations/_log_analytics_operations.py | 129 +- .../v2017_12_01/aio/operations/_operations.py | 48 +- .../v2017_12_01/aio/operations/_patch.py | 19 + .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 187 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 65 +- ...machine_scale_set_extensions_operations.py | 157 +- ...e_scale_set_rolling_upgrades_operations.py | 130 +- ...irtual_machine_scale_set_vms_operations.py | 502 ++-- .../_virtual_machine_scale_sets_operations.py | 787 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 701 +++-- .../compute/v2017_12_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 43 +- .../compute/v2017_12_01/models/_models_py3.py | 629 +++-- .../mgmt/compute/v2017_12_01/models/_patch.py | 19 + .../v2017_12_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 298 ++- .../operations/_images_operations.py | 344 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2017_12_01/operations/_operations.py | 67 +- .../compute/v2017_12_01/operations/_patch.py | 19 + .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 272 +- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 101 +- ...machine_scale_set_extensions_operations.py | 236 +- ...e_scale_set_rolling_upgrades_operations.py | 183 +- ...irtual_machine_scale_set_vms_operations.py | 738 ++++-- .../_virtual_machine_scale_sets_operations.py | 1204 +++++---- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 1072 +++++--- .../mgmt/compute/v2018_04_01/__init__.py | 13 +- .../v2018_04_01/_compute_management_client.py | 72 +- .../mgmt/compute/v2018_04_01/_version.py | 2 +- .../mgmt/compute/v2018_04_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 72 +- .../v2018_04_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- .../aio/operations/_disks_operations.py | 305 ++- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2018_04_01/aio/operations/_operations.py | 48 +- .../v2018_04_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../aio/operations/_snapshots_operations.py | 305 ++- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 65 +- ...machine_scale_set_extensions_operations.py | 152 +- ...e_scale_set_rolling_upgrades_operations.py | 120 +- ...irtual_machine_scale_set_vms_operations.py | 504 ++-- .../_virtual_machine_scale_sets_operations.py | 732 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 642 +++-- .../compute/v2018_04_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 51 +- .../compute/v2018_04_01/models/_models_py3.py | 743 +++--- .../mgmt/compute/v2018_04_01/models/_patch.py | 19 + .../v2018_04_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 287 ++- .../operations/_disks_operations.py | 444 ++-- .../operations/_images_operations.py | 330 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2018_04_01/operations/_operations.py | 67 +- .../compute/v2018_04_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 249 +- .../operations/_snapshots_operations.py | 444 ++-- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 294 ++- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 101 +- ...machine_scale_set_extensions_operations.py | 222 +- ...e_scale_set_rolling_upgrades_operations.py | 155 +- ...irtual_machine_scale_set_vms_operations.py | 682 +++-- .../_virtual_machine_scale_sets_operations.py | 1090 +++++--- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 913 ++++--- .../mgmt/compute/v2018_06_01/__init__.py | 13 +- .../v2018_06_01/_compute_management_client.py | 84 +- .../mgmt/compute/v2018_06_01/_version.py | 2 +- .../mgmt/compute/v2018_06_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 84 +- .../v2018_06_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- .../aio/operations/_disks_operations.py | 305 ++- .../aio/operations/_galleries_operations.py | 171 +- .../_gallery_image_versions_operations.py | 152 +- .../operations/_gallery_images_operations.py | 152 +- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2018_06_01/aio/operations/_operations.py | 48 +- .../v2018_06_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../aio/operations/_snapshots_operations.py | 305 ++- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 65 +- ...machine_scale_set_extensions_operations.py | 152 +- ...e_scale_set_rolling_upgrades_operations.py | 156 +- ...irtual_machine_scale_set_vms_operations.py | 512 ++-- .../_virtual_machine_scale_sets_operations.py | 732 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 686 +++-- .../compute/v2018_06_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 71 +- .../compute/v2018_06_01/models/_models_py3.py | 855 +++---- .../mgmt/compute/v2018_06_01/models/_patch.py | 19 + .../v2018_06_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 287 ++- .../operations/_disks_operations.py | 444 ++-- .../operations/_galleries_operations.py | 265 +- .../_gallery_image_versions_operations.py | 231 +- .../operations/_gallery_images_operations.py | 229 +- .../operations/_images_operations.py | 330 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2018_06_01/operations/_operations.py | 67 +- .../compute/v2018_06_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 249 +- .../operations/_snapshots_operations.py | 444 ++-- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 294 ++- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 101 +- ...machine_scale_set_extensions_operations.py | 222 +- ...e_scale_set_rolling_upgrades_operations.py | 199 +- ...irtual_machine_scale_set_vms_operations.py | 700 +++-- .../_virtual_machine_scale_sets_operations.py | 1090 +++++--- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 975 ++++--- .../mgmt/compute/v2018_09_30/__init__.py | 13 +- .../v2018_09_30/_compute_management_client.py | 8 +- .../mgmt/compute/v2018_09_30/_version.py | 2 +- .../mgmt/compute/v2018_09_30/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 8 +- .../v2018_09_30/aio/operations/__init__.py | 5 + .../aio/operations/_disks_operations.py | 305 ++- .../v2018_09_30/aio/operations/_patch.py | 19 + .../aio/operations/_snapshots_operations.py | 305 ++- .../compute/v2018_09_30/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 15 +- .../compute/v2018_09_30/models/_models_py3.py | 110 +- .../mgmt/compute/v2018_09_30/models/_patch.py | 19 + .../v2018_09_30/operations/__init__.py | 5 + .../operations/_disks_operations.py | 444 ++-- .../compute/v2018_09_30/operations/_patch.py | 19 + .../operations/_snapshots_operations.py | 444 ++-- .../mgmt/compute/v2018_10_01/__init__.py | 13 +- .../v2018_10_01/_compute_management_client.py | 64 +- .../mgmt/compute/v2018_10_01/_version.py | 2 +- .../mgmt/compute/v2018_10_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 64 +- .../v2018_10_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2018_10_01/aio/operations/_operations.py | 48 +- .../v2018_10_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 65 +- ...machine_scale_set_extensions_operations.py | 152 +- ...e_scale_set_rolling_upgrades_operations.py | 156 +- ...irtual_machine_scale_set_vms_operations.py | 512 ++-- .../_virtual_machine_scale_sets_operations.py | 732 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 686 +++-- .../compute/v2018_10_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 49 +- .../compute/v2018_10_01/models/_models_py3.py | 702 +++--- .../mgmt/compute/v2018_10_01/models/_patch.py | 19 + .../v2018_10_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 287 ++- .../operations/_images_operations.py | 330 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2018_10_01/operations/_operations.py | 67 +- .../compute/v2018_10_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 249 +- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 294 ++- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 101 +- ...machine_scale_set_extensions_operations.py | 222 +- ...e_scale_set_rolling_upgrades_operations.py | 199 +- ...irtual_machine_scale_set_vms_operations.py | 700 +++-- .../_virtual_machine_scale_sets_operations.py | 1090 +++++--- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 975 ++++--- .../mgmt/compute/v2019_03_01/__init__.py | 13 +- .../v2019_03_01/_compute_management_client.py | 100 +- .../mgmt/compute/v2019_03_01/_version.py | 2 +- .../mgmt/compute/v2019_03_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 100 +- .../v2019_03_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- .../_dedicated_host_groups_operations.py | 141 +- .../operations/_dedicated_hosts_operations.py | 205 +- .../aio/operations/_disks_operations.py | 305 ++- .../aio/operations/_galleries_operations.py | 171 +- ...gallery_application_versions_operations.py | 152 +- .../_gallery_applications_operations.py | 152 +- .../_gallery_image_versions_operations.py | 152 +- .../operations/_gallery_images_operations.py | 152 +- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2019_03_01/aio/operations/_operations.py | 48 +- .../v2019_03_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../aio/operations/_snapshots_operations.py | 305 ++- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 65 +- ...machine_scale_set_extensions_operations.py | 152 +- ...e_scale_set_rolling_upgrades_operations.py | 156 +- ...irtual_machine_scale_set_vms_operations.py | 516 ++-- .../_virtual_machine_scale_sets_operations.py | 751 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 686 +++-- .../compute/v2019_03_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 87 +- .../compute/v2019_03_01/models/_models_py3.py | 1047 ++++---- .../mgmt/compute/v2019_03_01/models/_patch.py | 19 + .../v2019_03_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 287 ++- .../_dedicated_host_groups_operations.py | 249 +- .../operations/_dedicated_hosts_operations.py | 298 ++- .../operations/_disks_operations.py | 444 ++-- .../operations/_galleries_operations.py | 265 +- ...gallery_application_versions_operations.py | 231 +- .../_gallery_applications_operations.py | 229 +- .../_gallery_image_versions_operations.py | 231 +- .../operations/_gallery_images_operations.py | 229 +- .../operations/_images_operations.py | 330 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2019_03_01/operations/_operations.py | 67 +- .../compute/v2019_03_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 249 +- .../operations/_snapshots_operations.py | 444 ++-- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 294 ++- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 101 +- ...machine_scale_set_extensions_operations.py | 222 +- ...e_scale_set_rolling_upgrades_operations.py | 199 +- ...irtual_machine_scale_set_vms_operations.py | 708 ++++-- .../_virtual_machine_scale_sets_operations.py | 1129 +++++---- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 977 ++++--- .../mgmt/compute/v2019_04_01/__init__.py | 13 +- .../v2019_04_01/_compute_management_client.py | 4 +- .../mgmt/compute/v2019_04_01/_version.py | 2 +- .../mgmt/compute/v2019_04_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 4 +- .../v2019_04_01/aio/operations/__init__.py | 5 + .../v2019_04_01/aio/operations/_patch.py | 19 + .../operations/_resource_skus_operations.py | 48 +- .../compute/v2019_04_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 7 +- .../compute/v2019_04_01/models/_models_py3.py | 14 +- .../mgmt/compute/v2019_04_01/models/_patch.py | 19 + .../v2019_04_01/operations/__init__.py | 5 + .../compute/v2019_04_01/operations/_patch.py | 19 + .../operations/_resource_skus_operations.py | 69 +- .../mgmt/compute/v2019_07_01/__init__.py | 13 +- .../v2019_07_01/_compute_management_client.py | 108 +- .../mgmt/compute/v2019_07_01/_version.py | 2 +- .../mgmt/compute/v2019_07_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 108 +- .../v2019_07_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- .../_dedicated_host_groups_operations.py | 141 +- .../operations/_dedicated_hosts_operations.py | 205 +- .../_disk_encryption_sets_operations.py | 220 +- .../aio/operations/_disks_operations.py | 305 ++- .../aio/operations/_galleries_operations.py | 220 +- ...gallery_application_versions_operations.py | 201 +- .../_gallery_applications_operations.py | 201 +- .../_gallery_image_versions_operations.py | 201 +- .../operations/_gallery_images_operations.py | 201 +- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2019_07_01/aio/operations/_operations.py | 48 +- .../v2019_07_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../aio/operations/_snapshots_operations.py | 305 ++- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 65 +- ...machine_scale_set_extensions_operations.py | 201 +- ...e_scale_set_rolling_upgrades_operations.py | 156 +- ...hine_scale_set_vm_extensions_operations.py | 199 +- ...irtual_machine_scale_set_vms_operations.py | 516 ++-- .../_virtual_machine_scale_sets_operations.py | 751 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 722 ++++-- .../compute/v2019_07_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 91 +- .../compute/v2019_07_01/models/_models_py3.py | 1213 +++++---- .../mgmt/compute/v2019_07_01/models/_patch.py | 19 + .../v2019_07_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 287 ++- .../_dedicated_host_groups_operations.py | 249 +- .../operations/_dedicated_hosts_operations.py | 298 ++- .../_disk_encryption_sets_operations.py | 337 ++- .../operations/_disks_operations.py | 444 ++-- .../operations/_galleries_operations.py | 337 ++- ...gallery_application_versions_operations.py | 303 ++- .../_gallery_applications_operations.py | 301 ++- .../_gallery_image_versions_operations.py | 303 ++- .../operations/_gallery_images_operations.py | 301 ++- .../operations/_images_operations.py | 330 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2019_07_01/operations/_operations.py | 67 +- .../compute/v2019_07_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 251 +- .../operations/_snapshots_operations.py | 444 ++-- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 294 ++- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 101 +- ...machine_scale_set_extensions_operations.py | 294 ++- ...e_scale_set_rolling_upgrades_operations.py | 199 +- ...hine_scale_set_vm_extensions_operations.py | 303 ++- ...irtual_machine_scale_set_vms_operations.py | 708 ++++-- .../_virtual_machine_scale_sets_operations.py | 1129 +++++---- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 1032 +++++--- .../mgmt/compute/v2019_11_01/__init__.py | 13 +- .../v2019_11_01/_compute_management_client.py | 12 +- .../mgmt/compute/v2019_11_01/_version.py | 2 +- .../mgmt/compute/v2019_11_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 12 +- .../v2019_11_01/aio/operations/__init__.py | 5 + .../_disk_encryption_sets_operations.py | 220 +- .../aio/operations/_disks_operations.py | 305 ++- .../v2019_11_01/aio/operations/_patch.py | 19 + .../aio/operations/_snapshots_operations.py | 305 ++- .../compute/v2019_11_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 19 +- .../compute/v2019_11_01/models/_models_py3.py | 144 +- .../mgmt/compute/v2019_11_01/models/_patch.py | 19 + .../v2019_11_01/operations/__init__.py | 5 + .../_disk_encryption_sets_operations.py | 337 ++- .../operations/_disks_operations.py | 444 ++-- .../compute/v2019_11_01/operations/_patch.py | 19 + .../operations/_snapshots_operations.py | 444 ++-- .../mgmt/compute/v2019_12_01/__init__.py | 13 +- .../v2019_12_01/_compute_management_client.py | 100 +- .../mgmt/compute/v2019_12_01/_version.py | 2 +- .../mgmt/compute/v2019_12_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 100 +- .../v2019_12_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- .../_dedicated_host_groups_operations.py | 141 +- .../operations/_dedicated_hosts_operations.py | 205 +- .../aio/operations/_galleries_operations.py | 220 +- ...gallery_application_versions_operations.py | 201 +- .../_gallery_applications_operations.py | 201 +- .../_gallery_image_versions_operations.py | 201 +- .../operations/_gallery_images_operations.py | 201 +- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2019_12_01/aio/operations/_operations.py | 48 +- .../v2019_12_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../operations/_ssh_public_keys_operations.py | 158 +- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 65 +- ...machine_scale_set_extensions_operations.py | 201 +- ...e_scale_set_rolling_upgrades_operations.py | 156 +- ...hine_scale_set_vm_extensions_operations.py | 199 +- ...irtual_machine_scale_set_vms_operations.py | 531 ++-- .../_virtual_machine_scale_sets_operations.py | 795 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 737 ++++-- .../compute/v2019_12_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 85 +- .../compute/v2019_12_01/models/_models_py3.py | 1111 ++++---- .../mgmt/compute/v2019_12_01/models/_patch.py | 19 + .../v2019_12_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 287 ++- .../_dedicated_host_groups_operations.py | 249 +- .../operations/_dedicated_hosts_operations.py | 298 ++- .../operations/_galleries_operations.py | 337 ++- ...gallery_application_versions_operations.py | 303 ++- .../_gallery_applications_operations.py | 301 ++- .../_gallery_image_versions_operations.py | 303 ++- .../operations/_gallery_images_operations.py | 301 ++- .../operations/_images_operations.py | 330 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2019_12_01/operations/_operations.py | 67 +- .../compute/v2019_12_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 251 +- .../operations/_ssh_public_keys_operations.py | 283 ++- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 294 ++- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 101 +- ...machine_scale_set_extensions_operations.py | 294 ++- ...e_scale_set_rolling_upgrades_operations.py | 199 +- ...hine_scale_set_vm_extensions_operations.py | 303 ++- ...irtual_machine_scale_set_vms_operations.py | 731 ++++-- .../_virtual_machine_scale_sets_operations.py | 1191 +++++---- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 1055 +++++--- .../mgmt/compute/v2020_05_01/__init__.py | 13 +- .../v2020_05_01/_compute_management_client.py | 16 +- .../mgmt/compute/v2020_05_01/_version.py | 2 +- .../mgmt/compute/v2020_05_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 16 +- .../v2020_05_01/aio/operations/__init__.py | 5 + .../operations/_disk_accesses_operations.py | 237 +- .../_disk_encryption_sets_operations.py | 220 +- .../aio/operations/_disks_operations.py | 305 ++- .../v2020_05_01/aio/operations/_patch.py | 19 + .../aio/operations/_snapshots_operations.py | 305 ++- .../compute/v2020_05_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 25 +- .../compute/v2020_05_01/models/_models_py3.py | 220 +- .../mgmt/compute/v2020_05_01/models/_patch.py | 19 + .../v2020_05_01/operations/__init__.py | 5 + .../operations/_disk_accesses_operations.py | 371 +-- .../_disk_encryption_sets_operations.py | 337 ++- .../operations/_disks_operations.py | 444 ++-- .../compute/v2020_05_01/operations/_patch.py | 19 + .../operations/_snapshots_operations.py | 444 ++-- .../mgmt/compute/v2020_06_01/__init__.py | 13 +- .../v2020_06_01/_compute_management_client.py | 84 +- .../mgmt/compute/v2020_06_01/_version.py | 2 +- .../mgmt/compute/v2020_06_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 84 +- .../v2020_06_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- .../_dedicated_host_groups_operations.py | 143 +- .../operations/_dedicated_hosts_operations.py | 205 +- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2020_06_01/aio/operations/_operations.py | 48 +- .../v2020_06_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../operations/_ssh_public_keys_operations.py | 158 +- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 233 +- ...machine_scale_set_extensions_operations.py | 201 +- ...e_scale_set_rolling_upgrades_operations.py | 156 +- ...hine_scale_set_vm_extensions_operations.py | 199 +- ...ne_scale_set_vm_run_commands_operations.py | 197 +- ...irtual_machine_scale_set_vms_operations.py | 548 ++-- .../_virtual_machine_scale_sets_operations.py | 795 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 795 ++++-- .../compute/v2020_06_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 79 +- .../compute/v2020_06_01/models/_models_py3.py | 977 ++++--- .../mgmt/compute/v2020_06_01/models/_patch.py | 19 + .../v2020_06_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 287 ++- .../_dedicated_host_groups_operations.py | 253 +- .../operations/_dedicated_hosts_operations.py | 298 ++- .../operations/_images_operations.py | 330 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2020_06_01/operations/_operations.py | 67 +- .../compute/v2020_06_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 251 +- .../operations/_ssh_public_keys_operations.py | 283 ++- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 294 ++- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 371 +-- ...machine_scale_set_extensions_operations.py | 294 ++- ...e_scale_set_rolling_upgrades_operations.py | 199 +- ...hine_scale_set_vm_extensions_operations.py | 303 ++- ...ne_scale_set_vm_run_commands_operations.py | 301 ++- ...irtual_machine_scale_set_vms_operations.py | 767 +++--- .../_virtual_machine_scale_sets_operations.py | 1191 +++++---- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 1151 +++++---- .../mgmt/compute/v2020_06_30/__init__.py | 13 +- .../v2020_06_30/_compute_management_client.py | 16 +- .../mgmt/compute/v2020_06_30/_version.py | 2 +- .../mgmt/compute/v2020_06_30/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 16 +- .../v2020_06_30/aio/operations/__init__.py | 5 + .../operations/_disk_accesses_operations.py | 237 +- .../_disk_encryption_sets_operations.py | 239 +- .../aio/operations/_disks_operations.py | 305 ++- .../v2020_06_30/aio/operations/_patch.py | 19 + .../aio/operations/_snapshots_operations.py | 305 ++- .../compute/v2020_06_30/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 27 +- .../compute/v2020_06_30/models/_models_py3.py | 222 +- .../mgmt/compute/v2020_06_30/models/_patch.py | 19 + .../v2020_06_30/operations/__init__.py | 5 + .../operations/_disk_accesses_operations.py | 371 +-- .../_disk_encryption_sets_operations.py | 373 +-- .../operations/_disks_operations.py | 444 ++-- .../compute/v2020_06_30/operations/_patch.py | 19 + .../operations/_snapshots_operations.py | 444 ++-- .../mgmt/compute/v2020_09_30/__init__.py | 13 +- .../v2020_09_30/_compute_management_client.py | 56 +- .../mgmt/compute/v2020_09_30/_version.py | 2 +- .../mgmt/compute/v2020_09_30/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 56 +- .../v2020_09_30/aio/operations/__init__.py | 5 + .../operations/_disk_accesses_operations.py | 358 ++- .../_disk_encryption_sets_operations.py | 239 +- .../_disk_restore_point_operations.py | 65 +- .../aio/operations/_disks_operations.py | 305 ++- .../aio/operations/_galleries_operations.py | 220 +- ...gallery_application_versions_operations.py | 201 +- .../_gallery_applications_operations.py | 201 +- .../_gallery_image_versions_operations.py | 201 +- .../operations/_gallery_images_operations.py | 201 +- .../_gallery_sharing_profile_operations.py | 80 +- .../v2020_09_30/aio/operations/_patch.py | 19 + .../_shared_galleries_operations.py | 65 +- ...hared_gallery_image_versions_operations.py | 65 +- .../_shared_gallery_images_operations.py | 65 +- .../aio/operations/_snapshots_operations.py | 305 ++- .../compute/v2020_09_30/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 59 +- .../compute/v2020_09_30/models/_models_py3.py | 552 ++-- .../mgmt/compute/v2020_09_30/models/_patch.py | 19 + .../v2020_09_30/operations/__init__.py | 5 + .../operations/_disk_accesses_operations.py | 566 +++-- .../_disk_encryption_sets_operations.py | 373 +-- .../_disk_restore_point_operations.py | 101 +- .../operations/_disks_operations.py | 444 ++-- .../operations/_galleries_operations.py | 339 ++- ...gallery_application_versions_operations.py | 303 ++- .../_gallery_applications_operations.py | 301 ++- .../_gallery_image_versions_operations.py | 303 ++- .../operations/_gallery_images_operations.py | 301 ++- .../_gallery_sharing_profile_operations.py | 106 +- .../compute/v2020_09_30/operations/_patch.py | 19 + .../_shared_galleries_operations.py | 103 +- ...hared_gallery_image_versions_operations.py | 103 +- .../_shared_gallery_images_operations.py | 103 +- .../operations/_snapshots_operations.py | 444 ++-- .../compute/v2020_10_01_preview/__init__.py | 13 +- .../_compute_management_client.py | 16 +- .../compute/v2020_10_01_preview/_version.py | 2 +- .../v2020_10_01_preview/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 16 +- .../aio/operations/__init__.py | 5 + ...cloud_service_role_instances_operations.py | 251 +- .../_cloud_service_roles_operations.py | 65 +- .../operations/_cloud_services_operations.py | 485 ++-- ...cloud_services_update_domain_operations.py | 111 +- .../aio/operations/_patch.py | 19 + .../v2020_10_01_preview/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 5 +- .../v2020_10_01_preview/models/_models_py3.py | 86 +- .../v2020_10_01_preview/models/_patch.py | 19 + .../operations/__init__.py | 5 + ...cloud_service_role_instances_operations.py | 393 +-- .../_cloud_service_roles_operations.py | 101 +- .../operations/_cloud_services_operations.py | 745 +++--- ...cloud_services_update_domain_operations.py | 171 +- .../v2020_10_01_preview/operations/_patch.py | 19 + .../mgmt/compute/v2020_12_01/__init__.py | 13 +- .../v2020_12_01/_compute_management_client.py | 108 +- .../mgmt/compute/v2020_12_01/_version.py | 2 +- .../mgmt/compute/v2020_12_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 108 +- .../v2020_12_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- .../_dedicated_host_groups_operations.py | 143 +- .../operations/_dedicated_hosts_operations.py | 205 +- .../operations/_disk_accesses_operations.py | 358 ++- .../_disk_encryption_sets_operations.py | 239 +- .../_disk_restore_point_operations.py | 152 +- .../aio/operations/_disks_operations.py | 305 ++- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2020_12_01/aio/operations/_operations.py | 48 +- .../v2020_12_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../aio/operations/_snapshots_operations.py | 305 ++- .../operations/_ssh_public_keys_operations.py | 158 +- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- ...ual_machine_images_edge_zone_operations.py | 114 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 233 +- ...machine_scale_set_extensions_operations.py | 201 +- ...e_scale_set_rolling_upgrades_operations.py | 156 +- ...hine_scale_set_vm_extensions_operations.py | 199 +- ...ne_scale_set_vm_run_commands_operations.py | 197 +- ...irtual_machine_scale_set_vms_operations.py | 548 ++-- .../_virtual_machine_scale_sets_operations.py | 814 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 844 +++++-- .../compute/v2020_12_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 123 +- .../compute/v2020_12_01/models/_models_py3.py | 1308 +++++----- .../mgmt/compute/v2020_12_01/models/_patch.py | 19 + .../v2020_12_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 287 ++- .../_dedicated_host_groups_operations.py | 253 +- .../operations/_dedicated_hosts_operations.py | 298 ++- .../operations/_disk_accesses_operations.py | 566 +++-- .../_disk_encryption_sets_operations.py | 373 +-- .../_disk_restore_point_operations.py | 229 +- .../operations/_disks_operations.py | 444 ++-- .../operations/_images_operations.py | 330 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2020_12_01/operations/_operations.py | 67 +- .../compute/v2020_12_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 251 +- .../operations/_snapshots_operations.py | 444 ++-- .../operations/_ssh_public_keys_operations.py | 283 ++- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 294 ++- ...ual_machine_images_edge_zone_operations.py | 207 +- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 371 +-- ...machine_scale_set_extensions_operations.py | 294 ++- ...e_scale_set_rolling_upgrades_operations.py | 199 +- ...hine_scale_set_vm_extensions_operations.py | 303 ++- ...ne_scale_set_vm_run_commands_operations.py | 301 ++- ...irtual_machine_scale_set_vms_operations.py | 769 +++--- .../_virtual_machine_scale_sets_operations.py | 1231 +++++---- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 1223 +++++---- .../mgmt/compute/v2021_03_01/__init__.py | 13 +- .../v2021_03_01/_compute_management_client.py | 116 +- .../mgmt/compute/v2021_03_01/_version.py | 2 +- .../mgmt/compute/v2021_03_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 116 +- .../v2021_03_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- ...ud_service_operating_systems_operations.py | 101 +- ...cloud_service_role_instances_operations.py | 243 +- .../_cloud_service_roles_operations.py | 65 +- .../operations/_cloud_services_operations.py | 485 ++-- ...cloud_services_update_domain_operations.py | 111 +- .../_dedicated_host_groups_operations.py | 141 +- .../operations/_dedicated_hosts_operations.py | 201 +- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2021_03_01/aio/operations/_operations.py | 48 +- .../v2021_03_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../_restore_point_collections_operations.py | 164 +- .../operations/_restore_points_operations.py | 133 +- .../operations/_ssh_public_keys_operations.py | 158 +- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- ...ual_machine_images_edge_zone_operations.py | 114 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 233 +- ...machine_scale_set_extensions_operations.py | 201 +- ...e_scale_set_rolling_upgrades_operations.py | 156 +- ...hine_scale_set_vm_extensions_operations.py | 199 +- ...ne_scale_set_vm_run_commands_operations.py | 197 +- ...irtual_machine_scale_set_vms_operations.py | 544 ++-- .../_virtual_machine_scale_sets_operations.py | 814 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 840 ++++-- .../compute/v2021_03_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 127 +- .../compute/v2021_03_01/models/_models_py3.py | 1383 +++++----- .../mgmt/compute/v2021_03_01/models/_patch.py | 19 + .../v2021_03_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 287 ++- ...ud_service_operating_systems_operations.py | 171 +- ...cloud_service_role_instances_operations.py | 385 +-- .../_cloud_service_roles_operations.py | 101 +- .../operations/_cloud_services_operations.py | 745 +++--- ...cloud_services_update_domain_operations.py | 171 +- .../_dedicated_host_groups_operations.py | 251 +- .../operations/_dedicated_hosts_operations.py | 294 ++- .../operations/_images_operations.py | 330 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2021_03_01/operations/_operations.py | 67 +- .../compute/v2021_03_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 251 +- .../_restore_point_collections_operations.py | 283 ++- .../operations/_restore_points_operations.py | 193 +- .../operations/_ssh_public_keys_operations.py | 283 ++- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 294 ++- ...ual_machine_images_edge_zone_operations.py | 207 +- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 371 +-- ...machine_scale_set_extensions_operations.py | 294 ++- ...e_scale_set_rolling_upgrades_operations.py | 199 +- ...hine_scale_set_vm_extensions_operations.py | 303 ++- ...ne_scale_set_vm_run_commands_operations.py | 301 ++- ...irtual_machine_scale_set_vms_operations.py | 765 ++++-- .../_virtual_machine_scale_sets_operations.py | 1233 +++++---- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 1219 +++++---- .../mgmt/compute/v2021_04_01/__init__.py | 13 +- .../v2021_04_01/_compute_management_client.py | 124 +- .../mgmt/compute/v2021_04_01/_version.py | 2 +- .../mgmt/compute/v2021_04_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 124 +- .../v2021_04_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- ..._capacity_reservation_groups_operations.py | 141 +- .../_capacity_reservations_operations.py | 201 +- .../_dedicated_host_groups_operations.py | 141 +- .../operations/_dedicated_hosts_operations.py | 201 +- .../operations/_disk_accesses_operations.py | 358 ++- .../_disk_encryption_sets_operations.py | 239 +- .../_disk_restore_point_operations.py | 152 +- .../aio/operations/_disks_operations.py | 305 ++- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2021_04_01/aio/operations/_operations.py | 48 +- .../v2021_04_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../_restore_point_collections_operations.py | 164 +- .../operations/_restore_points_operations.py | 133 +- .../aio/operations/_snapshots_operations.py | 305 ++- .../operations/_ssh_public_keys_operations.py | 158 +- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- ...ual_machine_images_edge_zone_operations.py | 114 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 233 +- ...machine_scale_set_extensions_operations.py | 201 +- ...e_scale_set_rolling_upgrades_operations.py | 156 +- ...hine_scale_set_vm_extensions_operations.py | 199 +- ...ne_scale_set_vm_run_commands_operations.py | 197 +- ...irtual_machine_scale_set_vms_operations.py | 544 ++-- .../_virtual_machine_scale_sets_operations.py | 814 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 840 ++++-- .../compute/v2021_04_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 159 +- .../compute/v2021_04_01/models/_models_py3.py | 1634 ++++++------ .../mgmt/compute/v2021_04_01/models/_patch.py | 19 + .../v2021_04_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 287 ++- ..._capacity_reservation_groups_operations.py | 264 +- .../_capacity_reservations_operations.py | 303 ++- .../_dedicated_host_groups_operations.py | 251 +- .../operations/_dedicated_hosts_operations.py | 294 ++- .../operations/_disk_accesses_operations.py | 566 +++-- .../_disk_encryption_sets_operations.py | 373 +-- .../_disk_restore_point_operations.py | 229 +- .../operations/_disks_operations.py | 444 ++-- .../operations/_images_operations.py | 330 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2021_04_01/operations/_operations.py | 67 +- .../compute/v2021_04_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 251 +- .../_restore_point_collections_operations.py | 283 ++- .../operations/_restore_points_operations.py | 193 +- .../operations/_snapshots_operations.py | 444 ++-- .../operations/_ssh_public_keys_operations.py | 283 ++- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 294 ++- ...ual_machine_images_edge_zone_operations.py | 207 +- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 371 +-- ...machine_scale_set_extensions_operations.py | 294 ++- ...e_scale_set_rolling_upgrades_operations.py | 199 +- ...hine_scale_set_vm_extensions_operations.py | 303 ++- ...ne_scale_set_vm_run_commands_operations.py | 301 ++- ...irtual_machine_scale_set_vms_operations.py | 765 ++++-- .../_virtual_machine_scale_sets_operations.py | 1233 +++++---- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 1219 +++++---- .../mgmt/compute/v2021_07_01/__init__.py | 13 +- .../v2021_07_01/_compute_management_client.py | 156 +- .../mgmt/compute/v2021_07_01/_version.py | 2 +- .../mgmt/compute/v2021_07_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 156 +- .../v2021_07_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- ..._capacity_reservation_groups_operations.py | 141 +- .../_capacity_reservations_operations.py | 201 +- .../_community_galleries_operations.py | 46 +- ...unity_gallery_image_versions_operations.py | 46 +- .../_community_gallery_images_operations.py | 46 +- .../_dedicated_host_groups_operations.py | 141 +- .../operations/_dedicated_hosts_operations.py | 201 +- .../aio/operations/_galleries_operations.py | 220 +- ...gallery_application_versions_operations.py | 201 +- .../_gallery_applications_operations.py | 201 +- .../_gallery_image_versions_operations.py | 201 +- .../operations/_gallery_images_operations.py | 201 +- .../_gallery_sharing_profile_operations.py | 80 +- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2021_07_01/aio/operations/_operations.py | 48 +- .../v2021_07_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../operations/_resource_skus_operations.py | 48 +- .../_restore_point_collections_operations.py | 164 +- .../operations/_restore_points_operations.py | 133 +- .../_shared_galleries_operations.py | 65 +- ...hared_gallery_image_versions_operations.py | 65 +- .../_shared_gallery_images_operations.py | 65 +- .../operations/_ssh_public_keys_operations.py | 158 +- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- ...ual_machine_images_edge_zone_operations.py | 114 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 233 +- ...machine_scale_set_extensions_operations.py | 201 +- ...e_scale_set_rolling_upgrades_operations.py | 156 +- ...hine_scale_set_vm_extensions_operations.py | 199 +- ...ne_scale_set_vm_run_commands_operations.py | 197 +- ...irtual_machine_scale_set_vms_operations.py | 544 ++-- .../_virtual_machine_scale_sets_operations.py | 814 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 840 ++++-- .../compute/v2021_07_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 171 +- .../compute/v2021_07_01/models/_models_py3.py | 1687 ++++++------- .../mgmt/compute/v2021_07_01/models/_patch.py | 19 + .../v2021_07_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 287 ++- ..._capacity_reservation_groups_operations.py | 264 +- .../_capacity_reservations_operations.py | 303 ++- .../_community_galleries_operations.py | 65 +- ...unity_gallery_image_versions_operations.py | 65 +- .../_community_gallery_images_operations.py | 65 +- .../_dedicated_host_groups_operations.py | 251 +- .../operations/_dedicated_hosts_operations.py | 294 ++- .../operations/_galleries_operations.py | 339 ++- ...gallery_application_versions_operations.py | 303 ++- .../_gallery_applications_operations.py | 301 ++- .../_gallery_image_versions_operations.py | 303 ++- .../operations/_gallery_images_operations.py | 301 ++- .../_gallery_sharing_profile_operations.py | 106 +- .../operations/_images_operations.py | 330 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2021_07_01/operations/_operations.py | 67 +- .../compute/v2021_07_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 251 +- .../operations/_resource_skus_operations.py | 71 +- .../_restore_point_collections_operations.py | 283 ++- .../operations/_restore_points_operations.py | 193 +- .../_shared_galleries_operations.py | 103 +- ...hared_gallery_image_versions_operations.py | 103 +- .../_shared_gallery_images_operations.py | 103 +- .../operations/_ssh_public_keys_operations.py | 283 ++- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 294 ++- ...ual_machine_images_edge_zone_operations.py | 207 +- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 371 +-- ...machine_scale_set_extensions_operations.py | 294 ++- ...e_scale_set_rolling_upgrades_operations.py | 199 +- ...hine_scale_set_vm_extensions_operations.py | 303 ++- ...ne_scale_set_vm_run_commands_operations.py | 301 ++- ...irtual_machine_scale_set_vms_operations.py | 765 ++++-- .../_virtual_machine_scale_sets_operations.py | 1233 +++++---- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 1221 +++++---- .../mgmt/compute/v2021_08_01/__init__.py | 13 +- .../v2021_08_01/_compute_management_client.py | 20 +- .../mgmt/compute/v2021_08_01/_version.py | 2 +- .../mgmt/compute/v2021_08_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 20 +- .../v2021_08_01/aio/operations/__init__.py | 5 + .../operations/_disk_accesses_operations.py | 358 ++- .../_disk_encryption_sets_operations.py | 239 +- .../_disk_restore_point_operations.py | 152 +- .../aio/operations/_disks_operations.py | 305 ++- .../v2021_08_01/aio/operations/_patch.py | 19 + .../aio/operations/_snapshots_operations.py | 305 ++- .../compute/v2021_08_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 33 +- .../compute/v2021_08_01/models/_models_py3.py | 343 ++- .../mgmt/compute/v2021_08_01/models/_patch.py | 19 + .../v2021_08_01/operations/__init__.py | 5 + .../operations/_disk_accesses_operations.py | 566 +++-- .../_disk_encryption_sets_operations.py | 373 +-- .../_disk_restore_point_operations.py | 229 +- .../operations/_disks_operations.py | 444 ++-- .../compute/v2021_08_01/operations/_patch.py | 19 + .../operations/_snapshots_operations.py | 444 ++-- .../mgmt/compute/v2021_10_01/__init__.py | 13 +- .../v2021_10_01/_compute_management_client.py | 24 +- .../mgmt/compute/v2021_10_01/_version.py | 2 +- .../mgmt/compute/v2021_10_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 24 +- .../v2021_10_01/aio/operations/__init__.py | 5 + .../aio/operations/_galleries_operations.py | 220 +- ...gallery_application_versions_operations.py | 201 +- .../_gallery_applications_operations.py | 201 +- .../_gallery_image_versions_operations.py | 201 +- .../operations/_gallery_images_operations.py | 201 +- .../_gallery_sharing_profile_operations.py | 80 +- .../v2021_10_01/aio/operations/_patch.py | 19 + .../compute/v2021_10_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 45 +- .../compute/v2021_10_01/models/_models_py3.py | 353 ++- .../mgmt/compute/v2021_10_01/models/_patch.py | 19 + .../v2021_10_01/operations/__init__.py | 5 + .../operations/_galleries_operations.py | 341 ++- ...gallery_application_versions_operations.py | 303 ++- .../_gallery_applications_operations.py | 301 ++- .../_gallery_image_versions_operations.py | 303 ++- .../operations/_gallery_images_operations.py | 301 ++- .../_gallery_sharing_profile_operations.py | 106 +- .../compute/v2021_10_01/operations/_patch.py | 19 + .../mgmt/compute/v2021_11_01/__init__.py | 13 +- .../v2021_11_01/_compute_management_client.py | 104 +- .../mgmt/compute/v2021_11_01/_version.py | 2 +- .../mgmt/compute/v2021_11_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 104 +- .../v2021_11_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- ..._capacity_reservation_groups_operations.py | 141 +- .../_capacity_reservations_operations.py | 201 +- .../_dedicated_host_groups_operations.py | 141 +- .../operations/_dedicated_hosts_operations.py | 237 +- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2021_11_01/aio/operations/_operations.py | 48 +- .../v2021_11_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../_restore_point_collections_operations.py | 164 +- .../operations/_restore_points_operations.py | 133 +- .../operations/_ssh_public_keys_operations.py | 158 +- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- ...ual_machine_images_edge_zone_operations.py | 114 +- .../_virtual_machine_images_operations.py | 114 +- ...virtual_machine_run_commands_operations.py | 233 +- ...machine_scale_set_extensions_operations.py | 201 +- ...e_scale_set_rolling_upgrades_operations.py | 156 +- ...hine_scale_set_vm_extensions_operations.py | 199 +- ...ne_scale_set_vm_run_commands_operations.py | 197 +- ...irtual_machine_scale_set_vms_operations.py | 544 ++-- .../_virtual_machine_scale_sets_operations.py | 814 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 840 ++++-- .../compute/v2021_11_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 139 +- .../compute/v2021_11_01/models/_models_py3.py | 1368 +++++----- .../mgmt/compute/v2021_11_01/models/_patch.py | 19 + .../v2021_11_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 296 ++- ..._capacity_reservation_groups_operations.py | 264 +- .../_capacity_reservations_operations.py | 303 ++- .../_dedicated_host_groups_operations.py | 260 +- .../operations/_dedicated_hosts_operations.py | 356 ++- .../operations/_images_operations.py | 339 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2021_11_01/operations/_operations.py | 67 +- .../compute/v2021_11_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 260 +- .../_restore_point_collections_operations.py | 283 ++- .../operations/_restore_points_operations.py | 195 +- .../operations/_ssh_public_keys_operations.py | 292 ++- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 303 ++- ...ual_machine_images_edge_zone_operations.py | 207 +- .../_virtual_machine_images_operations.py | 207 +- ...virtual_machine_run_commands_operations.py | 371 +-- ...machine_scale_set_extensions_operations.py | 303 ++- ...e_scale_set_rolling_upgrades_operations.py | 226 +- ...hine_scale_set_vm_extensions_operations.py | 303 ++- ...ne_scale_set_vm_run_commands_operations.py | 301 ++- ...irtual_machine_scale_set_vms_operations.py | 851 ++++--- .../_virtual_machine_scale_sets_operations.py | 1306 ++++++---- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 1320 ++++++---- .../mgmt/compute/v2021_12_01/__init__.py | 13 +- .../v2021_12_01/_compute_management_client.py | 20 +- .../mgmt/compute/v2021_12_01/_version.py | 2 +- .../mgmt/compute/v2021_12_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 20 +- .../v2021_12_01/aio/operations/__init__.py | 5 + .../operations/_disk_accesses_operations.py | 358 ++- .../_disk_encryption_sets_operations.py | 239 +- .../_disk_restore_point_operations.py | 152 +- .../aio/operations/_disks_operations.py | 305 ++- .../v2021_12_01/aio/operations/_patch.py | 19 + .../aio/operations/_snapshots_operations.py | 305 ++- .../compute/v2021_12_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 37 +- .../compute/v2021_12_01/models/_models_py3.py | 376 ++- .../mgmt/compute/v2021_12_01/models/_patch.py | 19 + .../v2021_12_01/operations/__init__.py | 5 + .../operations/_disk_accesses_operations.py | 566 +++-- .../_disk_encryption_sets_operations.py | 373 +-- .../_disk_restore_point_operations.py | 229 +- .../operations/_disks_operations.py | 444 ++-- .../compute/v2021_12_01/operations/_patch.py | 19 + .../operations/_snapshots_operations.py | 444 ++-- .../mgmt/compute/v2022_01_03/__init__.py | 13 +- .../v2022_01_03/_compute_management_client.py | 48 +- .../mgmt/compute/v2022_01_03/_version.py | 2 +- .../mgmt/compute/v2022_01_03/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 48 +- .../v2022_01_03/aio/operations/__init__.py | 5 + .../_community_galleries_operations.py | 46 +- ...unity_gallery_image_versions_operations.py | 65 +- .../_community_gallery_images_operations.py | 65 +- .../aio/operations/_galleries_operations.py | 220 +- ...gallery_application_versions_operations.py | 201 +- .../_gallery_applications_operations.py | 201 +- .../_gallery_image_versions_operations.py | 201 +- .../operations/_gallery_images_operations.py | 201 +- .../_gallery_sharing_profile_operations.py | 80 +- .../v2022_01_03/aio/operations/_patch.py | 19 + .../_shared_galleries_operations.py | 65 +- ...hared_gallery_image_versions_operations.py | 65 +- .../_shared_gallery_images_operations.py | 65 +- .../compute/v2022_01_03/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 45 +- .../compute/v2022_01_03/models/_models_py3.py | 487 ++-- .../mgmt/compute/v2022_01_03/models/_patch.py | 19 + .../v2022_01_03/operations/__init__.py | 5 + .../_community_galleries_operations.py | 65 +- ...unity_gallery_image_versions_operations.py | 101 +- .../_community_gallery_images_operations.py | 101 +- .../operations/_galleries_operations.py | 341 ++- ...gallery_application_versions_operations.py | 303 ++- .../_gallery_applications_operations.py | 301 ++- .../_gallery_image_versions_operations.py | 303 ++- .../operations/_gallery_images_operations.py | 301 ++- .../_gallery_sharing_profile_operations.py | 106 +- .../compute/v2022_01_03/operations/_patch.py | 19 + .../_shared_galleries_operations.py | 103 +- ...hared_gallery_image_versions_operations.py | 103 +- .../_shared_gallery_images_operations.py | 103 +- .../mgmt/compute/v2022_03_01/__init__.py | 13 +- .../v2022_03_01/_compute_management_client.py | 104 +- .../mgmt/compute/v2022_03_01/_version.py | 2 +- .../mgmt/compute/v2022_03_01/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 104 +- .../v2022_03_01/aio/operations/__init__.py | 5 + .../_availability_sets_operations.py | 160 +- ..._capacity_reservation_groups_operations.py | 141 +- .../_capacity_reservations_operations.py | 201 +- .../_dedicated_host_groups_operations.py | 141 +- .../operations/_dedicated_hosts_operations.py | 237 +- .../aio/operations/_images_operations.py | 220 +- .../operations/_log_analytics_operations.py | 129 +- .../v2022_03_01/aio/operations/_operations.py | 48 +- .../v2022_03_01/aio/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 141 +- .../_restore_point_collections_operations.py | 164 +- .../operations/_restore_points_operations.py | 133 +- .../operations/_ssh_public_keys_operations.py | 158 +- .../aio/operations/_usage_operations.py | 48 +- ...ual_machine_extension_images_operations.py | 80 +- .../_virtual_machine_extensions_operations.py | 199 +- ...ual_machine_images_edge_zone_operations.py | 114 +- .../_virtual_machine_images_operations.py | 131 +- ...virtual_machine_run_commands_operations.py | 233 +- ...machine_scale_set_extensions_operations.py | 201 +- ...e_scale_set_rolling_upgrades_operations.py | 156 +- ...hine_scale_set_vm_extensions_operations.py | 199 +- ...ne_scale_set_vm_run_commands_operations.py | 197 +- ...irtual_machine_scale_set_vms_operations.py | 544 ++-- .../_virtual_machine_scale_sets_operations.py | 814 ++++-- .../_virtual_machine_sizes_operations.py | 48 +- .../_virtual_machines_operations.py | 840 ++++-- .../compute/v2022_03_01/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 143 +- .../compute/v2022_03_01/models/_models_py3.py | 1422 +++++------ .../mgmt/compute/v2022_03_01/models/_patch.py | 19 + .../v2022_03_01/operations/__init__.py | 5 + .../_availability_sets_operations.py | 296 ++- ..._capacity_reservation_groups_operations.py | 264 +- .../_capacity_reservations_operations.py | 303 ++- .../_dedicated_host_groups_operations.py | 260 +- .../operations/_dedicated_hosts_operations.py | 356 ++- .../operations/_images_operations.py | 339 ++- .../operations/_log_analytics_operations.py | 178 +- .../v2022_03_01/operations/_operations.py | 67 +- .../compute/v2022_03_01/operations/_patch.py | 19 + .../_proximity_placement_groups_operations.py | 260 +- .../_restore_point_collections_operations.py | 283 ++- .../operations/_restore_points_operations.py | 195 +- .../operations/_ssh_public_keys_operations.py | 292 ++- .../operations/_usage_operations.py | 67 +- ...ual_machine_extension_images_operations.py | 139 +- .../_virtual_machine_extensions_operations.py | 303 ++- ...ual_machine_images_edge_zone_operations.py | 207 +- .../_virtual_machine_images_operations.py | 241 +- ...virtual_machine_run_commands_operations.py | 371 +-- ...machine_scale_set_extensions_operations.py | 303 ++- ...e_scale_set_rolling_upgrades_operations.py | 226 +- ...hine_scale_set_vm_extensions_operations.py | 303 ++- ...ne_scale_set_vm_run_commands_operations.py | 301 ++- ...irtual_machine_scale_set_vms_operations.py | 851 ++++--- .../_virtual_machine_scale_sets_operations.py | 1306 ++++++---- .../_virtual_machine_sizes_operations.py | 67 +- .../_virtual_machines_operations.py | 1320 ++++++---- .../mgmt/compute/v2022_03_02/__init__.py | 13 +- .../v2022_03_02/_compute_management_client.py | 20 +- .../mgmt/compute/v2022_03_02/_version.py | 2 +- .../mgmt/compute/v2022_03_02/aio/__init__.py | 13 +- .../aio/_compute_management_client.py | 20 +- .../v2022_03_02/aio/operations/__init__.py | 5 + .../operations/_disk_accesses_operations.py | 358 ++- .../_disk_encryption_sets_operations.py | 239 +- .../_disk_restore_point_operations.py | 152 +- .../aio/operations/_disks_operations.py | 305 ++- .../v2022_03_02/aio/operations/_patch.py | 19 + .../aio/operations/_snapshots_operations.py | 305 ++- .../compute/v2022_03_02/models/__init__.py | 6 +- .../_compute_management_client_enums.py | 39 +- .../compute/v2022_03_02/models/_models_py3.py | 389 ++- .../mgmt/compute/v2022_03_02/models/_patch.py | 19 + .../v2022_03_02/operations/__init__.py | 5 + .../operations/_disk_accesses_operations.py | 566 +++-- .../_disk_encryption_sets_operations.py | 373 +-- .../_disk_restore_point_operations.py | 229 +- .../operations/_disks_operations.py | 444 ++-- .../compute/v2022_03_02/operations/_patch.py | 19 + .../operations/_snapshots_operations.py | 444 ++-- .../mgmt/compute/v2022_04_04/__init__.py | 23 + .../v2022_04_04/_compute_management_client.py | 124 + .../compute/v2022_04_04/_configuration.py | 74 + .../mgmt/compute/v2022_04_04/_metadata.json | 106 + .../azure/mgmt/compute/v2022_04_04/_patch.py | 19 + .../azure/mgmt/compute/v2022_04_04/_vendor.py | 27 + .../mgmt/compute/v2022_04_04/_version.py | 9 + .../mgmt/compute/v2022_04_04/aio/__init__.py | 20 + .../aio/_compute_management_client.py | 121 + .../compute/v2022_04_04/aio/_configuration.py | 73 + .../mgmt/compute/v2022_04_04/aio/_patch.py | 19 + .../v2022_04_04/aio/operations/__init__.py | 26 + ...ud_service_operating_systems_operations.py | 345 +++ ...cloud_service_role_instances_operations.py | 859 +++++++ .../_cloud_service_roles_operations.py | 203 ++ .../operations/_cloud_services_operations.py | 1529 +++++++++++ ...cloud_services_update_domain_operations.py | 350 +++ .../v2022_04_04/aio/operations/_patch.py | 19 + .../compute/v2022_04_04/models/__init__.py | 133 + .../_compute_management_client_enums.py | 55 + .../compute/v2022_04_04/models/_models_py3.py | 2246 +++++++++++++++++ .../mgmt/compute/v2022_04_04/models/_patch.py | 19 + .../v2022_04_04/operations/__init__.py | 26 + ...ud_service_operating_systems_operations.py | 490 ++++ ...cloud_service_role_instances_operations.py | 1179 +++++++++ .../_cloud_service_roles_operations.py | 281 +++ .../operations/_cloud_services_operations.py | 2054 +++++++++++++++ ...cloud_services_update_domain_operations.py | 475 ++++ .../compute/v2022_04_04/operations/_patch.py | 19 + .../azure/mgmt/compute/v2022_04_04/py.typed | 1 + 1353 files changed, 183253 insertions(+), 107859 deletions(-) create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_compute_management_client.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_configuration.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_metadata.json create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_vendor.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_version.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/_compute_management_client.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/_configuration.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_service_operating_systems_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_service_role_instances_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_service_roles_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_services_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_services_update_domain_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/_compute_management_client_enums.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/_models_py3.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/__init__.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_service_operating_systems_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_service_role_instances_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_service_roles_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_services_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_services_update_domain_operations.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_patch.py create mode 100644 sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/py.typed diff --git a/sdk/compute/azure-mgmt-compute/_meta.json b/sdk/compute/azure-mgmt-compute/_meta.json index 02079ce23e7c..a0fcec6737f2 100644 --- a/sdk/compute/azure-mgmt-compute/_meta.json +++ b/sdk/compute/azure-mgmt-compute/_meta.json @@ -1,11 +1,11 @@ { "autorest": "3.7.2", "use": [ - "@autorest/python@5.13.0", + "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "2d6cb29af754f48a08f94cb6113bb1f01a4e0eb9", + "commit": "ae49a3a8ec93cf74f3bbc24e1a2baefa75d42e75", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/compute/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/compute/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/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/compute/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_compute_management_client.py index baa83b5e2bda..ccbe0d55cf71 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/_compute_management_client.py @@ -56,7 +56,7 @@ class ComputeManagementClient(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 = '2022-03-02' + DEFAULT_API_VERSION = '2022-04-04' _PROFILE_TAG = "azure.mgmt.compute.ComputeManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -64,16 +64,15 @@ class ComputeManagementClient(MultiApiClientMixin, _SDKClient): 'availability_sets': '2022-03-01', 'capacity_reservation_groups': '2022-03-01', 'capacity_reservations': '2022-03-01', - 'cloud_service_operating_systems': '2021-03-01', - 'cloud_service_role_instances': '2021-03-01', - 'cloud_service_roles': '2021-03-01', - 'cloud_services': '2021-03-01', - 'cloud_services_update_domain': '2021-03-01', 'community_galleries': '2022-01-03', 'community_gallery_image_versions': '2022-01-03', 'community_gallery_images': '2022-01-03', 'dedicated_host_groups': '2022-03-01', 'dedicated_hosts': '2022-03-01', + 'disk_accesses': '2022-03-02', + 'disk_encryption_sets': '2022-03-02', + 'disk_restore_point': '2022-03-02', + 'disks': '2022-03-02', 'galleries': '2022-01-03', 'gallery_application_versions': '2022-01-03', 'gallery_applications': '2022-01-03', @@ -90,6 +89,7 @@ class ComputeManagementClient(MultiApiClientMixin, _SDKClient): 'shared_galleries': '2022-01-03', 'shared_gallery_image_versions': '2022-01-03', 'shared_gallery_images': '2022-01-03', + 'snapshots': '2022-03-02', 'ssh_public_keys': '2022-03-01', 'usage': '2022-03-01', 'virtual_machine_extension_images': '2022-03-01', @@ -164,6 +164,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2022-01-03: :mod:`v2022_01_03.models` * 2022-03-01: :mod:`v2022_03_01.models` * 2022-03-02: :mod:`v2022_03_02.models` + * 2022-04-04: :mod:`v2022_04_04.models` """ if api_version == '2015-06-15': from .v2015_06_15 import models @@ -258,6 +259,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-03-02': from .v2022_03_02 import models return models + elif api_version == '2022-04-04': + from .v2022_04_04 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -373,10 +377,13 @@ def cloud_service_operating_systems(self): """Instance depends on the API version: * 2021-03-01: :class:`CloudServiceOperatingSystemsOperations` + * 2022-04-04: :class:`CloudServiceOperatingSystemsOperations` """ api_version = self._get_api_version('cloud_service_operating_systems') if api_version == '2021-03-01': from .v2021_03_01.operations import CloudServiceOperatingSystemsOperations as OperationClass + elif api_version == '2022-04-04': + from .v2022_04_04.operations import CloudServiceOperatingSystemsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cloud_service_operating_systems'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -387,12 +394,15 @@ def cloud_service_role_instances(self): * 2020-10-01-preview: :class:`CloudServiceRoleInstancesOperations` * 2021-03-01: :class:`CloudServiceRoleInstancesOperations` + * 2022-04-04: :class:`CloudServiceRoleInstancesOperations` """ api_version = self._get_api_version('cloud_service_role_instances') if api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import CloudServiceRoleInstancesOperations as OperationClass elif api_version == '2021-03-01': from .v2021_03_01.operations import CloudServiceRoleInstancesOperations as OperationClass + elif api_version == '2022-04-04': + from .v2022_04_04.operations import CloudServiceRoleInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cloud_service_role_instances'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -403,12 +413,15 @@ def cloud_service_roles(self): * 2020-10-01-preview: :class:`CloudServiceRolesOperations` * 2021-03-01: :class:`CloudServiceRolesOperations` + * 2022-04-04: :class:`CloudServiceRolesOperations` """ api_version = self._get_api_version('cloud_service_roles') if api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import CloudServiceRolesOperations as OperationClass elif api_version == '2021-03-01': from .v2021_03_01.operations import CloudServiceRolesOperations as OperationClass + elif api_version == '2022-04-04': + from .v2022_04_04.operations import CloudServiceRolesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cloud_service_roles'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -419,12 +432,15 @@ def cloud_services(self): * 2020-10-01-preview: :class:`CloudServicesOperations` * 2021-03-01: :class:`CloudServicesOperations` + * 2022-04-04: :class:`CloudServicesOperations` """ api_version = self._get_api_version('cloud_services') if api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import CloudServicesOperations as OperationClass elif api_version == '2021-03-01': from .v2021_03_01.operations import CloudServicesOperations as OperationClass + elif api_version == '2022-04-04': + from .v2022_04_04.operations import CloudServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cloud_services'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -435,12 +451,15 @@ def cloud_services_update_domain(self): * 2020-10-01-preview: :class:`CloudServicesUpdateDomainOperations` * 2021-03-01: :class:`CloudServicesUpdateDomainOperations` + * 2022-04-04: :class:`CloudServicesUpdateDomainOperations` """ api_version = self._get_api_version('cloud_services_update_domain') if api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import CloudServicesUpdateDomainOperations as OperationClass elif api_version == '2021-03-01': from .v2021_03_01.operations import CloudServicesUpdateDomainOperations as OperationClass + elif api_version == '2022-04-04': + from .v2022_04_04.operations import CloudServicesUpdateDomainOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cloud_services_update_domain'".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/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_compute_management_client.py index a34ff3796e53..f4d5c41bdece 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/aio/_compute_management_client.py @@ -55,7 +55,7 @@ class ComputeManagementClient(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 = '2022-03-02' + DEFAULT_API_VERSION = '2022-04-04' _PROFILE_TAG = "azure.mgmt.compute.ComputeManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -63,16 +63,15 @@ class ComputeManagementClient(MultiApiClientMixin, _SDKClient): 'availability_sets': '2022-03-01', 'capacity_reservation_groups': '2022-03-01', 'capacity_reservations': '2022-03-01', - 'cloud_service_operating_systems': '2021-03-01', - 'cloud_service_role_instances': '2021-03-01', - 'cloud_service_roles': '2021-03-01', - 'cloud_services': '2021-03-01', - 'cloud_services_update_domain': '2021-03-01', 'community_galleries': '2022-01-03', 'community_gallery_image_versions': '2022-01-03', 'community_gallery_images': '2022-01-03', 'dedicated_host_groups': '2022-03-01', 'dedicated_hosts': '2022-03-01', + 'disk_accesses': '2022-03-02', + 'disk_encryption_sets': '2022-03-02', + 'disk_restore_point': '2022-03-02', + 'disks': '2022-03-02', 'galleries': '2022-01-03', 'gallery_application_versions': '2022-01-03', 'gallery_applications': '2022-01-03', @@ -89,6 +88,7 @@ class ComputeManagementClient(MultiApiClientMixin, _SDKClient): 'shared_galleries': '2022-01-03', 'shared_gallery_image_versions': '2022-01-03', 'shared_gallery_images': '2022-01-03', + 'snapshots': '2022-03-02', 'ssh_public_keys': '2022-03-01', 'usage': '2022-03-01', 'virtual_machine_extension_images': '2022-03-01', @@ -163,6 +163,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2022-01-03: :mod:`v2022_01_03.models` * 2022-03-01: :mod:`v2022_03_01.models` * 2022-03-02: :mod:`v2022_03_02.models` + * 2022-04-04: :mod:`v2022_04_04.models` """ if api_version == '2015-06-15': from ..v2015_06_15 import models @@ -257,6 +258,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-03-02': from ..v2022_03_02 import models return models + elif api_version == '2022-04-04': + from ..v2022_04_04 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -372,10 +376,13 @@ def cloud_service_operating_systems(self): """Instance depends on the API version: * 2021-03-01: :class:`CloudServiceOperatingSystemsOperations` + * 2022-04-04: :class:`CloudServiceOperatingSystemsOperations` """ api_version = self._get_api_version('cloud_service_operating_systems') if api_version == '2021-03-01': from ..v2021_03_01.aio.operations import CloudServiceOperatingSystemsOperations as OperationClass + elif api_version == '2022-04-04': + from ..v2022_04_04.aio.operations import CloudServiceOperatingSystemsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cloud_service_operating_systems'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -386,12 +393,15 @@ def cloud_service_role_instances(self): * 2020-10-01-preview: :class:`CloudServiceRoleInstancesOperations` * 2021-03-01: :class:`CloudServiceRoleInstancesOperations` + * 2022-04-04: :class:`CloudServiceRoleInstancesOperations` """ api_version = self._get_api_version('cloud_service_role_instances') if api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import CloudServiceRoleInstancesOperations as OperationClass elif api_version == '2021-03-01': from ..v2021_03_01.aio.operations import CloudServiceRoleInstancesOperations as OperationClass + elif api_version == '2022-04-04': + from ..v2022_04_04.aio.operations import CloudServiceRoleInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cloud_service_role_instances'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -402,12 +412,15 @@ def cloud_service_roles(self): * 2020-10-01-preview: :class:`CloudServiceRolesOperations` * 2021-03-01: :class:`CloudServiceRolesOperations` + * 2022-04-04: :class:`CloudServiceRolesOperations` """ api_version = self._get_api_version('cloud_service_roles') if api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import CloudServiceRolesOperations as OperationClass elif api_version == '2021-03-01': from ..v2021_03_01.aio.operations import CloudServiceRolesOperations as OperationClass + elif api_version == '2022-04-04': + from ..v2022_04_04.aio.operations import CloudServiceRolesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cloud_service_roles'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -418,12 +431,15 @@ def cloud_services(self): * 2020-10-01-preview: :class:`CloudServicesOperations` * 2021-03-01: :class:`CloudServicesOperations` + * 2022-04-04: :class:`CloudServicesOperations` """ api_version = self._get_api_version('cloud_services') if api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import CloudServicesOperations as OperationClass elif api_version == '2021-03-01': from ..v2021_03_01.aio.operations import CloudServicesOperations as OperationClass + elif api_version == '2022-04-04': + from ..v2022_04_04.aio.operations import CloudServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cloud_services'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -434,12 +450,15 @@ def cloud_services_update_domain(self): * 2020-10-01-preview: :class:`CloudServicesUpdateDomainOperations` * 2021-03-01: :class:`CloudServicesUpdateDomainOperations` + * 2022-04-04: :class:`CloudServicesUpdateDomainOperations` """ api_version = self._get_api_version('cloud_services_update_domain') if api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import CloudServicesUpdateDomainOperations as OperationClass elif api_version == '2021-03-01': from ..v2021_03_01.aio.operations import CloudServicesUpdateDomainOperations as OperationClass + elif api_version == '2022-04-04': + from ..v2022_04_04.aio.operations import CloudServicesUpdateDomainOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'cloud_services_update_domain'".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/compute/azure-mgmt-compute/azure/mgmt/compute/models.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models.py index 696d9a2de577..8b3eccca6dc4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/models.py @@ -4,8 +4,8 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from .v2021_03_01.models import * from .v2021_07_01.models import * from .v2022_01_03.models import * from .v2022_03_01.models import * from .v2022_03_02.models import * +from .v2022_04_04.models import * diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/_compute_management_client.py index ebdc84b1e892..cbd118f0b3ad 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/_compute_management_client.py @@ -78,15 +78,33 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/_compute_management_client.py index 7d972ff78908..3ea06a949281 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/_compute_management_client.py @@ -79,15 +79,33 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/__init__.py index e6a93279734f..930cd59256fd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/__init__.py @@ -16,6 +16,9 @@ from ._virtual_machine_scale_sets_operations import VirtualMachineScaleSetsOperations from ._virtual_machine_scale_set_vms_operations import VirtualMachineScaleSetVMsOperations +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__ = [ 'AvailabilitySetsOperations', 'VirtualMachineExtensionImagesOperations', @@ -27,3 +30,5 @@ 'VirtualMachineScaleSetsOperations', 'VirtualMachineScaleSetVMsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_availability_sets_operations.py index bea5a0fca315..4b779ba7a220 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.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.compute.v2015_06_15.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2015_06_15.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,7 +120,7 @@ async def delete( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: + ) -> Optional[_models.OperationStatusResponse]: """Delete an availability set. :param resource_group_name: The name of the resource group. @@ -128,13 +132,16 @@ async def delete( :rtype: ~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_delete_request( @@ -143,11 +150,13 @@ async def delete( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -176,7 +185,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -188,13 +197,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2015_06_15.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -203,11 +215,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,7 +247,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -245,13 +259,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2015_06_15.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -260,9 +277,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -271,9 +290,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -312,7 +333,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -327,13 +348,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -343,9 +367,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -355,9 +381,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_usage_operations.py index e50c0ffe434c..9d2453c2874a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.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.compute.v2015_06_15.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2015_06_15.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_extension_images_operations.py index 2772ef79c79e..a26892ebcc1e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.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.compute.v2015_06_15.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_extensions_operations.py index aa913b20b922..474fa1abc61a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.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.compute.v2015_06_15.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -319,14 +348,17 @@ async def _delete_initial( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -370,7 +404,7 @@ async def begin_delete( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -393,35 +427,45 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -442,7 +486,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -458,13 +502,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -475,11 +522,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_images_operations.py index 6cae40a833b0..482af43cecc0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.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.compute.v2015_06_15.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_scale_set_vms_operations.py index 58a453e70708..cfc3de631c25 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.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.compute.v2015_06_15.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( self, @@ -53,14 +52,17 @@ async def _reimage_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_reimage_request_initial( @@ -70,11 +72,13 @@ async def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -104,7 +108,7 @@ async def begin_reimage( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -127,35 +131,45 @@ async def begin_reimage( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -174,14 +188,17 @@ async def _deallocate_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -191,11 +208,13 @@ async def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -225,7 +244,7 @@ async def begin_deallocate( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and releases the compute resources it uses. You are not billed for the compute resources of this virtual machine once it is deallocated. @@ -250,35 +269,45 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -297,14 +326,17 @@ async def _delete_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_delete_request_initial( @@ -314,11 +346,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -348,7 +382,7 @@ async def begin_delete( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -371,35 +405,45 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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( @@ -419,7 +463,7 @@ async def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -433,13 +477,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineScaleSetVM] request = build_get_request( @@ -449,11 +496,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -481,7 +530,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -495,13 +544,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -511,11 +563,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -545,7 +599,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -569,13 +623,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -588,9 +645,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -603,9 +662,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -644,14 +705,17 @@ async def _power_off_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_power_off_request_initial( @@ -661,11 +725,13 @@ async def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -695,7 +761,7 @@ async def begin_power_off( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -720,35 +786,45 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -767,14 +843,17 @@ async def _restart_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_restart_request_initial( @@ -784,11 +863,13 @@ async def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -818,7 +899,7 @@ async def begin_restart( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Restarts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -841,35 +922,45 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -888,14 +979,17 @@ async def _start_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_start_request_initial( @@ -905,11 +999,13 @@ async def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -939,7 +1035,7 @@ async def begin_start( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Starts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -962,35 +1058,45 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_scale_sets_operations.py index 0c7ac15126e3..631069a7ef43 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.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.compute.v2015_06_15.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, name=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('VirtualMachineScaleSet', 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( @@ -180,14 +194,17 @@ async def _delete_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_delete_request_initial( @@ -196,11 +213,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -229,7 +248,7 @@ async def begin_delete( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a VM scale set. :param resource_group_name: The name of the resource group. @@ -250,34 +269,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -296,7 +325,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -308,13 +337,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -323,11 +355,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -352,17 +386,20 @@ async def _deallocate_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -377,11 +414,13 @@ async def _deallocate_initial( content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -409,9 +448,9 @@ async def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. @@ -438,37 +477,47 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -485,17 +534,20 @@ async def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -507,11 +559,13 @@ async def _delete_instances_initial( content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -539,9 +593,9 @@ async def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -565,37 +619,47 @@ async def begin_delete_instances( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -614,7 +678,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -626,13 +690,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -641,11 +708,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -671,7 +740,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -683,13 +752,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -698,9 +770,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -709,9 +783,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -748,7 +824,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -760,13 +836,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -774,9 +853,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -784,9 +865,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -825,7 +908,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -840,13 +923,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -856,9 +942,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -868,9 +956,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -907,17 +997,20 @@ async def _power_off_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -932,11 +1025,13 @@ async def _power_off_initial( content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -964,9 +1059,9 @@ async def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -993,37 +1088,47 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1040,17 +1145,20 @@ async def _restart_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1065,11 +1173,13 @@ async def _restart_initial( content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1097,9 +1207,9 @@ async def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1124,37 +1234,47 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1171,17 +1291,20 @@ async def _start_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1196,11 +1319,13 @@ async def _start_initial( content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1228,9 +1353,9 @@ async def begin_start( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1255,37 +1380,47 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1302,17 +1437,20 @@ async def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1324,11 +1462,13 @@ async def _update_instances_initial( content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1356,9 +1496,9 @@ async def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. @@ -1382,37 +1522,47 @@ async def begin_update_instances( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1430,14 +1580,17 @@ async def _reimage_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_reimage_request_initial( @@ -1446,11 +1599,13 @@ async def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1479,7 +1634,7 @@ async def begin_reimage( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1500,34 +1655,44 @@ async def begin_reimage( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_sizes_operations.py index 8de9e7cce536..df8f5d1b5478 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.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.compute.v2015_06_15.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes for a subscription in a location. :param location: The location upon which virtual-machine-sizes is queried. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machines_operations.py index adaa4dafc441..231d8e915ecf 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.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.compute.v2015_06_15.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -73,11 +75,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,9 +109,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -131,37 +135,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -178,17 +192,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -200,11 +217,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -234,9 +253,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -259,37 +278,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -307,14 +336,17 @@ async def _delete_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_delete_request_initial( @@ -323,11 +355,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -356,7 +390,7 @@ async def begin_delete( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to delete a virtual machine. :param resource_group_name: The name of the resource group. @@ -377,34 +411,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -424,28 +468,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -455,11 +502,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -485,14 +534,17 @@ async def _deallocate_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -501,11 +553,13 @@ async def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -534,7 +588,7 @@ async def begin_deallocate( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses. @@ -556,34 +610,44 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -602,7 +666,7 @@ async def generalize( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.OperationStatusResponse": + ) -> _models.OperationStatusResponse: """Sets the state of the virtual machine to generalized. :param resource_group_name: The name of the resource group. @@ -614,13 +678,16 @@ async def generalize( :rtype: ~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] request = build_generalize_request( @@ -629,11 +696,13 @@ async def generalize( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -659,7 +728,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -672,13 +741,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -687,9 +759,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -698,9 +772,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -737,7 +813,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -748,13 +824,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -762,9 +841,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -772,9 +853,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -813,7 +896,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -828,13 +911,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -844,9 +930,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -856,9 +944,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -896,14 +986,17 @@ async def _power_off_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_power_off_request_initial( @@ -912,11 +1005,13 @@ async def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -945,7 +1040,7 @@ async def begin_power_off( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine. @@ -967,34 +1062,44 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1012,14 +1117,17 @@ async def _restart_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_restart_request_initial( @@ -1028,11 +1136,13 @@ async def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1061,7 +1171,7 @@ async def begin_restart( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to restart a virtual machine. :param resource_group_name: The name of the resource group. @@ -1082,34 +1192,44 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1127,14 +1247,17 @@ async def _start_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_start_request_initial( @@ -1143,11 +1266,13 @@ async def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1176,7 +1301,7 @@ async def begin_start( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to start a virtual machine. :param resource_group_name: The name of the resource group. @@ -1197,34 +1322,44 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1242,14 +1377,17 @@ async def _redeploy_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_redeploy_request_initial( @@ -1258,11 +1396,13 @@ async def _redeploy_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1291,7 +1431,7 @@ async def begin_redeploy( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine, moves it to a new node, and powers it back on. :param resource_group_name: The name of the resource group. @@ -1312,34 +1452,44 @@ async def begin_redeploy( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/__init__.py index fcaae5a1e669..2c7d6e3e691f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/__init__.py @@ -104,7 +104,9 @@ VirtualMachineScaleSetSkuScaleType, VirtualMachineSizeTypes, ) - +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__ = [ 'AdditionalUnattendContent', 'ApiEntityReference', @@ -201,3 +203,5 @@ 'VirtualMachineScaleSetSkuScaleType', 'VirtualMachineSizeTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/_compute_management_client_enums.py index 3e95e391f3ab..7512c7346267 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -22,7 +21,7 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -35,14 +34,14 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -50,7 +49,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -58,7 +57,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -66,7 +65,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -77,14 +76,14 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTOMATIC = "Automatic" MANUAL = "Manual" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. For more information about virtual machine sizes, see `Sizes for virtual machines `_. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/_models_py3.py index 82f413dbb7cb..f7fe317b69ab 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AdditionalUnattendContent(msrest.serialization.Model): @@ -25,7 +27,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2015_06_15.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -46,7 +48,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -59,7 +61,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2015_06_15.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -127,8 +129,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -302,7 +304,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -349,7 +351,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -476,8 +478,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2015_06_15.models.CachingTypes :ivar create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -485,7 +486,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2015_06_15.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -515,10 +516,10 @@ def __init__( *, lun: int, name: str, - vhd: "VirtualHardDisk", - create_option: Union[str, "DiskCreateOptionTypes"], - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: "_models.VirtualHardDisk", + create_option: Union[str, "_models.DiskCreateOptionTypes"], + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, **kwargs ): @@ -538,8 +539,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2015_06_15.models.CachingTypes :keyword create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -547,7 +547,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2015_06_15.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -609,7 +609,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -650,8 +650,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: "KeyVaultSecretReference", - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: "_models.KeyVaultSecretReference", + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -688,7 +688,7 @@ def __init__( self, *, name: Optional[str] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -715,8 +715,8 @@ class HardwareProfile(msrest.serialization.Model): :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", @@ -736,7 +736,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -750,8 +750,8 @@ def __init__( :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", @@ -860,7 +860,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2015_06_15.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -882,7 +882,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -891,7 +891,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2015_06_15.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -933,7 +933,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -972,7 +972,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -1005,7 +1005,7 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, **kwargs ): """ @@ -1038,7 +1038,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1128,7 +1128,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -1195,8 +1195,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2015_06_15.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -1212,8 +1212,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2015_06_15.models.CachingTypes :ivar create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -1221,7 +1220,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2015_06_15.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1250,12 +1249,12 @@ def __init__( self, *, name: str, - vhd: "VirtualHardDisk", - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: "_models.VirtualHardDisk", + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, **kwargs ): @@ -1263,7 +1262,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2015_06_15.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -1279,8 +1278,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2015_06_15.models.CachingTypes :keyword create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -1288,7 +1286,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2015_06_15.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1311,8 +1309,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2015_06_15.models.OperatingSystemTypes """ @@ -1327,12 +1325,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2015_06_15.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -1417,9 +1415,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -1646,7 +1644,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -1728,9 +1726,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -1788,8 +1786,7 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual". :vartype mode: str or ~azure.mgmt.compute.v2015_06_15.models.UpgradeMode """ @@ -1800,7 +1797,7 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, **kwargs ): """ @@ -1808,8 +1805,7 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual". :paramtype mode: str or ~azure.mgmt.compute.v2015_06_15.models.UpgradeMode """ super(UpgradePolicy, self).__init__(**kwargs) @@ -1854,7 +1850,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -1976,8 +1972,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -2114,13 +2110,13 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -2203,8 +2199,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2382,7 +2378,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -2447,7 +2443,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -2584,8 +2580,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2791,9 +2787,9 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, **kwargs ): """ @@ -2863,11 +2859,11 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2921,7 +2917,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachine"]] = None, + value: Optional[List["_models.VirtualMachine"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2993,9 +2989,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, provisioning_state: Optional[str] = None, over_provision: Optional[bool] = None, **kwargs @@ -3126,7 +3122,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs ): """ @@ -3167,7 +3163,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -3244,9 +3240,9 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + subnet: Optional["_models.ApiEntityReference"] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -3288,7 +3284,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineScaleSet"]] = None, + value: Optional[List["_models.VirtualMachineScaleSet"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -3361,7 +3357,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineScaleSet"]] = None, + value: Optional[List["_models.VirtualMachineScaleSet"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -3410,7 +3406,7 @@ def __init__( name: str, id: Optional[str] = None, primary: Optional[bool] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, **kwargs ): """ @@ -3445,7 +3441,7 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -3467,20 +3463,19 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2015_06_15.models.CachingTypes :ivar create_option: Required. Specifies how the virtual machines in the scale set should be created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2015_06_15.models.DiskCreateOptionTypes :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2015_06_15.models.OperatingSystemTypes :ivar image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before using it to attach to the Virtual Machine. If SourceImage is provided, the destination @@ -3508,10 +3503,10 @@ def __init__( self, *, name: str, - create_option: Union[str, "DiskCreateOptionTypes"], - caching: Optional[Union[str, "CachingTypes"]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + caching: Optional[Union[str, "_models.CachingTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, **kwargs ): @@ -3521,20 +3516,19 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2015_06_15.models.CachingTypes :keyword create_option: Required. Specifies how the virtual machines in the scale set should be created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2015_06_15.models.DiskCreateOptionTypes :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2015_06_15.models.OperatingSystemTypes :keyword image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before using it to attach to the Virtual Machine. If SourceImage is provided, the destination @@ -3615,9 +3609,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -3722,8 +3716,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetSkuScaleType """ @@ -3772,8 +3765,8 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, **kwargs ): """ @@ -3896,13 +3889,13 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, provisioning_state: Optional[str] = None, license_type: Optional[str] = None, **kwargs @@ -4104,11 +4097,11 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -4162,7 +4155,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineScaleSetVM"]] = None, + value: Optional[List["_models.VirtualMachineScaleSetVM"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -4204,10 +4197,10 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, **kwargs ): """ @@ -4308,7 +4301,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -4387,8 +4380,8 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -4433,7 +4426,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -4448,8 +4441,8 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :vartype protocol: str or ~azure.mgmt.compute.v2015_06_15.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault @@ -4469,14 +4462,14 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2015_06_15.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/__init__.py index e6a93279734f..930cd59256fd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/__init__.py @@ -16,6 +16,9 @@ from ._virtual_machine_scale_sets_operations import VirtualMachineScaleSetsOperations from ._virtual_machine_scale_set_vms_operations import VirtualMachineScaleSetVMsOperations +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__ = [ 'AvailabilitySetsOperations', 'VirtualMachineExtensionImagesOperations', @@ -27,3 +30,5 @@ 'VirtualMachineScaleSetsOperations', 'VirtualMachineScaleSetVMsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_availability_sets_operations.py index 87e7ac171e74..6f721eea8586 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,9 +78,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -91,18 +95,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -113,9 +115,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -127,18 +132,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -148,9 +151,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -161,18 +167,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -183,9 +187,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -197,51 +204,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2015_06_15.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -255,14 +258,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2015_06_15.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -274,11 +280,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -305,7 +313,7 @@ def delete( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: + ) -> Optional[_models.OperationStatusResponse]: """Delete an availability set. :param resource_group_name: The name of the resource group. @@ -317,13 +325,16 @@ def delete( :rtype: ~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_delete_request( @@ -332,11 +343,13 @@ def delete( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -365,7 +378,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -377,13 +390,16 @@ def get( :rtype: ~azure.mgmt.compute.v2015_06_15.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.AvailabilitySet] request = build_get_request( @@ -392,11 +408,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -422,7 +440,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -434,13 +452,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2015_06_15.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -449,9 +470,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -460,9 +483,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -501,7 +526,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -516,13 +541,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -532,9 +560,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -544,9 +574,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_usage_operations.py index 963494612170..34a3d87b9c74 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.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.compute.v2015_06_15.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2015_06_15.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_extension_images_operations.py index b899b43d4597..5dcc0da7c807 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2015_06_15.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_extensions_operations.py index 3a07bbe5b841..64dba6f222ee 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,9 +129,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,18 +147,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -167,9 +170,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -182,61 +188,60 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2015_06_15.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -249,11 +254,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -284,9 +291,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -313,17 +320,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -331,20 +341,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -362,17 +379,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -385,11 +405,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -416,9 +438,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -445,17 +467,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -463,20 +488,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -495,14 +527,17 @@ def _delete_initial( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_delete_request_initial( @@ -512,11 +547,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -546,7 +583,7 @@ def begin_delete( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -569,35 +606,45 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -618,7 +665,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -634,13 +681,16 @@ def get( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -651,11 +701,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_images_operations.py index 6326dda98bd7..02b1f508589c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2015_06_15.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_scale_set_vms_operations.py index b8c84445c78a..0030b9232267 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,6 +17,7 @@ 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 @@ -35,9 +36,12 @@ def build_reimage_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -50,18 +54,16 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -73,9 +75,12 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -88,18 +93,16 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -111,9 +114,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -126,18 +132,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -149,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -164,18 +171,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +192,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -202,18 +210,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -228,9 +234,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -242,24 +251,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -271,9 +278,12 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -286,18 +296,16 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -309,9 +317,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -324,18 +335,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -347,9 +356,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -362,42 +374,38 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2015_06_15.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( self, @@ -405,14 +413,17 @@ def _reimage_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_reimage_request_initial( @@ -422,11 +433,13 @@ def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,7 +469,7 @@ def begin_reimage( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -479,35 +492,45 @@ def begin_reimage( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -526,14 +549,17 @@ def _deallocate_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -543,11 +569,13 @@ def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -577,7 +605,7 @@ def begin_deallocate( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and releases the compute resources it uses. You are not billed for the compute resources of this virtual machine once it is deallocated. @@ -602,35 +630,45 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -649,14 +687,17 @@ def _delete_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_delete_request_initial( @@ -666,11 +707,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -700,7 +743,7 @@ def begin_delete( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -723,35 +766,45 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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( @@ -771,7 +824,7 @@ def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -785,13 +838,16 @@ def get( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -801,11 +857,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -833,7 +891,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -847,13 +905,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -863,11 +924,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -897,7 +960,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -921,13 +984,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -940,9 +1006,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -955,9 +1023,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -996,14 +1066,17 @@ def _power_off_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_power_off_request_initial( @@ -1013,11 +1086,13 @@ def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1047,7 +1122,7 @@ def begin_power_off( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -1072,35 +1147,45 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1119,14 +1204,17 @@ def _restart_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_restart_request_initial( @@ -1136,11 +1224,13 @@ def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1170,7 +1260,7 @@ def begin_restart( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Restarts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1193,35 +1283,45 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1240,14 +1340,17 @@ def _start_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_start_request_initial( @@ -1257,11 +1360,13 @@ def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1291,7 +1396,7 @@ def begin_start( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Starts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1314,35 +1419,45 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_scale_sets_operations.py index 93a6705a5a14..34cbf7ee49b0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,9 +80,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -93,18 +97,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -115,9 +117,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -129,18 +134,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -150,14 +153,17 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +175,18 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -194,14 +198,17 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -213,20 +220,18 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -239,9 +244,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -253,18 +261,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -274,9 +280,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -287,18 +296,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -307,9 +314,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -319,18 +329,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -341,9 +349,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -355,18 +366,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -376,14 +385,17 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -395,20 +407,18 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -420,14 +430,17 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -439,20 +452,18 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -464,14 +475,17 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -483,20 +497,18 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -508,14 +520,17 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -527,20 +542,18 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -553,9 +566,12 @@ def build_reimage_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -567,58 +583,57 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.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.compute.v2015_06_15.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -630,11 +645,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -664,9 +681,9 @@ def begin_create_or_update( self, resource_group_name: str, name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -689,37 +706,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, name=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('VirtualMachineScaleSet', 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( @@ -737,14 +764,17 @@ def _delete_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_delete_request_initial( @@ -753,11 +783,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -786,7 +818,7 @@ def begin_delete( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a VM scale set. :param resource_group_name: The name of the resource group. @@ -807,34 +839,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -853,7 +895,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -865,13 +907,16 @@ def get( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineScaleSet] request = build_get_request( @@ -880,11 +925,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -909,17 +956,20 @@ def _deallocate_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -934,11 +984,13 @@ def _deallocate_initial( content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -966,9 +1018,9 @@ def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. @@ -995,37 +1047,47 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1042,17 +1104,20 @@ def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1064,11 +1129,13 @@ def _delete_instances_initial( content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1096,9 +1163,9 @@ def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1122,37 +1189,47 @@ def begin_delete_instances( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1171,7 +1248,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1183,13 +1260,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1198,11 +1278,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1228,7 +1310,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1240,13 +1322,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1255,9 +1340,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1266,9 +1353,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1305,7 +1394,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1317,13 +1406,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1331,9 +1423,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1341,9 +1435,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1382,7 +1478,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1397,13 +1493,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1413,9 +1512,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1425,9 +1526,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1464,17 +1567,20 @@ def _power_off_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1489,11 +1595,13 @@ def _power_off_initial( content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1521,9 +1629,9 @@ def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -1550,37 +1658,47 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1597,17 +1715,20 @@ def _restart_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1622,11 +1743,13 @@ def _restart_initial( content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1654,9 +1777,9 @@ def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1681,37 +1804,47 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1728,17 +1861,20 @@ def _start_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1753,11 +1889,13 @@ def _start_initial( content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1785,9 +1923,9 @@ def begin_start( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1812,37 +1950,47 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1859,17 +2007,20 @@ def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1881,11 +2032,13 @@ def _update_instances_initial( content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1913,9 +2066,9 @@ def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. @@ -1939,37 +2092,47 @@ def begin_update_instances( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1987,14 +2150,17 @@ def _reimage_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_reimage_request_initial( @@ -2003,11 +2169,13 @@ def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2036,7 +2204,7 @@ def begin_reimage( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2057,34 +2225,44 @@ def begin_reimage( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_sizes_operations.py index 7a588960eca0..f524bf860dd9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2015_06_15.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes for a subscription in a location. :param location: The location upon which virtual-machine-sizes is queried. @@ -98,13 +98,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -113,9 +116,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -124,9 +129,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machines_operations.py index ae2fdaaa1083..aba94f6c31a0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2015_06_15/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -161,9 +164,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -199,9 +203,12 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -213,18 +220,16 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -235,9 +240,12 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -249,18 +257,16 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -270,9 +276,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -283,18 +292,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -303,9 +310,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -315,18 +325,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -337,9 +345,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -351,18 +362,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -373,9 +382,12 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -387,18 +399,16 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -409,9 +419,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -423,18 +436,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -445,9 +456,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -459,18 +473,16 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -481,9 +493,12 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + _headers = case_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -495,58 +510,57 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.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.compute.v2015_06_15.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -558,11 +572,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -590,9 +606,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -616,37 +632,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -663,17 +689,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - 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 + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -685,11 +714,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -719,9 +750,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -743,37 +774,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -791,14 +832,17 @@ def _delete_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_delete_request_initial( @@ -807,11 +851,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -840,7 +886,7 @@ def begin_delete( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to delete a virtual machine. :param resource_group_name: The name of the resource group. @@ -861,34 +907,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -908,28 +964,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2015_06_15.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -939,11 +998,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -969,14 +1030,17 @@ def _deallocate_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -985,11 +1049,13 @@ def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1018,7 +1084,7 @@ def begin_deallocate( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses. @@ -1040,34 +1106,44 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1086,7 +1162,7 @@ def generalize( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.OperationStatusResponse": + ) -> _models.OperationStatusResponse: """Sets the state of the virtual machine to generalized. :param resource_group_name: The name of the resource group. @@ -1098,13 +1174,16 @@ def generalize( :rtype: ~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] request = build_generalize_request( @@ -1113,11 +1192,13 @@ def generalize( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1143,7 +1224,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1156,13 +1237,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1171,9 +1255,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1182,9 +1268,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1221,7 +1309,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1232,13 +1320,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1246,9 +1337,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1256,9 +1349,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1297,7 +1392,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1312,13 +1407,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2015_06_15.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1328,9 +1426,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1340,9 +1440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1380,14 +1482,17 @@ def _power_off_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_power_off_request_initial( @@ -1396,11 +1501,13 @@ def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1429,7 +1536,7 @@ def begin_power_off( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine. @@ -1451,34 +1558,44 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1496,14 +1613,17 @@ def _restart_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_restart_request_initial( @@ -1512,11 +1632,13 @@ def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1545,7 +1667,7 @@ def begin_restart( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to restart a virtual machine. :param resource_group_name: The name of the resource group. @@ -1566,34 +1688,44 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1611,14 +1743,17 @@ def _start_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_start_request_initial( @@ -1627,11 +1762,13 @@ def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1660,7 +1797,7 @@ def begin_start( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to start a virtual machine. :param resource_group_name: The name of the resource group. @@ -1681,34 +1818,44 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1726,14 +1873,17 @@ def _redeploy_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse]] request = build_redeploy_request_initial( @@ -1742,11 +1892,13 @@ def _redeploy_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1775,7 +1927,7 @@ def begin_redeploy( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine, moves it to a new node, and powers it back on. :param resource_group_name: The name of the resource group. @@ -1796,34 +1948,44 @@ def begin_redeploy( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2015_06_15.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2015-06-15") # type: 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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/__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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_compute_management_client.py index 0a5493b3e2c4..971edc2fd42f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_compute_management_client.py @@ -78,15 +78,33 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/_compute_management_client.py index 3b4ee72dc335..1c9e862d4d87 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/_compute_management_client.py @@ -79,15 +79,33 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/__init__.py index 266148781f3e..fc77b1d80981 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/__init__.py @@ -16,6 +16,9 @@ from ._virtual_machine_scale_sets_operations import VirtualMachineScaleSetsOperations from ._virtual_machine_scale_set_vms_operations import VirtualMachineScaleSetVMsOperations +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__ = [ 'AvailabilitySetsOperations', 'VirtualMachineExtensionImagesOperations', @@ -27,3 +30,5 @@ 'VirtualMachineScaleSetsOperations', 'VirtualMachineScaleSetVMsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_availability_sets_operations.py index c63164a29039..1b3e7fd5c185 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2016_03_30.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,7 +120,7 @@ async def delete( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: + ) -> Optional[_models.OperationStatusResponse]: """Delete an availability set. :param resource_group_name: The name of the resource group. @@ -128,13 +132,16 @@ async def delete( :rtype: ~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request( @@ -143,11 +150,13 @@ async def delete( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -176,7 +185,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -188,13 +197,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_03_30.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -203,11 +215,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,7 +247,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -246,13 +260,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -261,9 +278,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -272,9 +291,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -312,7 +333,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -324,13 +345,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -339,9 +363,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -350,9 +376,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -391,7 +419,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -406,13 +434,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +453,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -434,9 +467,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_usage_operations.py index 5ad1c3f681d3..6c2a033b6ad7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_extension_images_operations.py index e521c8720fae..cacae40c3d07 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_extensions_operations.py index 11a3a5692d65..43d8ca049e64 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -319,14 +348,17 @@ async def _delete_initial( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -370,7 +404,7 @@ async def begin_delete( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -393,35 +427,45 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -442,7 +486,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -458,13 +502,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -475,11 +522,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_images_operations.py index 70ae933979dd..5102313354c4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_scale_set_vms_operations.py index 7f20ce5310f0..6f5f681930de 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( self, @@ -53,14 +52,17 @@ async def _reimage_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_request_initial( @@ -70,11 +72,13 @@ async def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -104,7 +108,7 @@ async def begin_reimage( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -127,35 +131,45 @@ async def begin_reimage( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -174,14 +188,17 @@ async def _deallocate_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -191,11 +208,13 @@ async def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -225,7 +244,7 @@ async def begin_deallocate( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and releases the compute resources it uses. You are not billed for the compute resources of this virtual machine once it is deallocated. @@ -250,35 +269,45 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -297,14 +326,17 @@ async def _delete_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -314,11 +346,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -348,7 +382,7 @@ async def begin_delete( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -371,35 +405,45 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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( @@ -419,7 +463,7 @@ async def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -433,13 +477,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -449,11 +496,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -481,7 +530,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -495,13 +544,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -511,11 +563,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -545,7 +599,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -569,13 +623,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -588,9 +645,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -603,9 +662,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -644,14 +705,17 @@ async def _power_off_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -661,11 +725,13 @@ async def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -695,7 +761,7 @@ async def begin_power_off( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -720,35 +786,45 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -767,14 +843,17 @@ async def _restart_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -784,11 +863,13 @@ async def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -818,7 +899,7 @@ async def begin_restart( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Restarts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -841,35 +922,45 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -888,14 +979,17 @@ async def _start_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -905,11 +999,13 @@ async def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -939,7 +1035,7 @@ async def begin_start( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Starts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -962,35 +1058,45 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_scale_sets_operations.py index 8660ebdc4e9c..90b132061fd3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, name=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('VirtualMachineScaleSet', 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( @@ -180,14 +194,17 @@ async def _delete_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -196,11 +213,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -229,7 +248,7 @@ async def begin_delete( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a VM scale set. :param resource_group_name: The name of the resource group. @@ -250,34 +269,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -296,7 +325,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -308,13 +337,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -323,11 +355,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -352,17 +386,20 @@ async def _deallocate_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -377,11 +414,13 @@ async def _deallocate_initial( content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -409,9 +448,9 @@ async def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. @@ -438,37 +477,47 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -485,17 +534,20 @@ async def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -507,11 +559,13 @@ async def _delete_instances_initial( content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -539,9 +593,9 @@ async def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -565,37 +619,47 @@ async def begin_delete_instances( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -614,7 +678,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -626,13 +690,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -641,11 +708,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -671,7 +740,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -683,13 +752,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -698,9 +770,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -709,9 +783,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -748,7 +824,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -760,13 +836,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -774,9 +853,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -784,9 +865,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -825,7 +908,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -840,13 +923,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -856,9 +942,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -868,9 +956,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -907,17 +997,20 @@ async def _power_off_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -932,11 +1025,13 @@ async def _power_off_initial( content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -964,9 +1059,9 @@ async def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -993,37 +1088,47 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1040,17 +1145,20 @@ async def _restart_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1065,11 +1173,13 @@ async def _restart_initial( content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1097,9 +1207,9 @@ async def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1124,37 +1234,47 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1171,17 +1291,20 @@ async def _start_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1196,11 +1319,13 @@ async def _start_initial( content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1228,9 +1353,9 @@ async def begin_start( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1255,37 +1380,47 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1302,17 +1437,20 @@ async def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # 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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1324,11 +1462,13 @@ async def _update_instances_initial( content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1356,9 +1496,9 @@ async def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. @@ -1382,37 +1522,47 @@ async def begin_update_instances( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1430,14 +1580,17 @@ async def _reimage_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_request_initial( @@ -1446,11 +1599,13 @@ async def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1479,7 +1634,7 @@ async def begin_reimage( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1500,34 +1655,44 @@ async def begin_reimage( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_sizes_operations.py index 6b0473e99828..7a7547fd5a87 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes for a subscription in a location. :param location: The location upon which virtual-machine-sizes is queried. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machines_operations.py index 2a0010097970..7820ed8feaac 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_extensions( @@ -54,7 +53,7 @@ async def get_extensions( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -68,13 +67,16 @@ async def get_extensions( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_get_extensions_request( @@ -84,11 +86,13 @@ async def get_extensions( api_version=api_version, expand=expand, template_url=self.get_extensions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,17 +117,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -135,11 +142,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -167,9 +176,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -193,37 +202,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -240,17 +259,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -262,11 +284,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -296,9 +320,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -321,37 +345,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -369,14 +403,17 @@ async def _delete_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -385,11 +422,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -418,7 +457,7 @@ async def begin_delete( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to delete a virtual machine. :param resource_group_name: The name of the resource group. @@ -439,34 +478,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -486,28 +535,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -517,11 +569,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -547,14 +601,17 @@ async def _deallocate_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -563,11 +620,13 @@ async def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -596,7 +655,7 @@ async def begin_deallocate( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses. @@ -618,34 +677,44 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -664,7 +733,7 @@ async def generalize( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.OperationStatusResponse": + ) -> _models.OperationStatusResponse: """Sets the state of the virtual machine to generalized. :param resource_group_name: The name of the resource group. @@ -676,13 +745,16 @@ async def generalize( :rtype: ~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] request = build_generalize_request( @@ -691,11 +763,13 @@ async def generalize( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -721,7 +795,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -734,13 +808,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -749,9 +826,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -760,9 +839,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -799,7 +880,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -810,13 +891,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -824,9 +908,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -834,9 +920,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -875,7 +963,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -890,13 +978,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -906,9 +997,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -918,9 +1011,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -958,14 +1053,17 @@ async def _power_off_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -974,11 +1072,13 @@ async def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1007,7 +1107,7 @@ async def begin_power_off( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine. @@ -1029,34 +1129,44 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1074,14 +1184,17 @@ async def _restart_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -1090,11 +1203,13 @@ async def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1123,7 +1238,7 @@ async def begin_restart( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to restart a virtual machine. :param resource_group_name: The name of the resource group. @@ -1144,34 +1259,44 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1189,14 +1314,17 @@ async def _start_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1205,11 +1333,13 @@ async def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1238,7 +1368,7 @@ async def begin_start( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to start a virtual machine. :param resource_group_name: The name of the resource group. @@ -1259,34 +1389,44 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1304,14 +1444,17 @@ async def _redeploy_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_redeploy_request_initial( @@ -1320,11 +1463,13 @@ async def _redeploy_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1353,7 +1498,7 @@ async def begin_redeploy( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine, moves it to a new node, and powers it back on. :param resource_group_name: The name of the resource group. @@ -1374,34 +1519,44 @@ async def begin_redeploy( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/__init__.py index ceec73e9e5c1..0d4a565c321a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/__init__.py @@ -107,7 +107,9 @@ VirtualMachineScaleSetSkuScaleType, VirtualMachineSizeTypes, ) - +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__ = [ 'AdditionalUnattendContent', 'ApiEntityReference', @@ -207,3 +209,5 @@ 'VirtualMachineScaleSetSkuScaleType', 'VirtualMachineSizeTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_compute_management_client_enums.py index ce8f4fa08a3d..8cb8e29a5f3e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -22,7 +21,7 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -35,14 +34,14 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -50,7 +49,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -58,7 +57,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -66,7 +65,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -77,14 +76,14 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTOMATIC = "Automatic" MANUAL = "Manual" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. For more information about virtual machine sizes, see `Sizes for virtual machines `_. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_models_py3.py index 264f6dd55a01..411f97371795 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AdditionalUnattendContent(msrest.serialization.Model): @@ -25,7 +27,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2016_03_30.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -46,7 +48,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -59,7 +61,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2016_03_30.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -127,8 +129,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -302,7 +304,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -349,7 +351,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -476,8 +478,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2016_03_30.models.CachingTypes :ivar create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -485,7 +486,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2016_03_30.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -515,10 +516,10 @@ def __init__( *, lun: int, name: str, - vhd: "VirtualHardDisk", - create_option: Union[str, "DiskCreateOptionTypes"], - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: "_models.VirtualHardDisk", + create_option: Union[str, "_models.DiskCreateOptionTypes"], + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, **kwargs ): @@ -538,8 +539,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2016_03_30.models.CachingTypes :keyword create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -547,7 +547,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2016_03_30.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -609,7 +609,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -644,8 +644,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -682,7 +682,7 @@ def __init__( self, *, name: Optional[str] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -709,8 +709,8 @@ class HardwareProfile(msrest.serialization.Model): :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", @@ -732,7 +732,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -746,8 +746,8 @@ def __init__( :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", @@ -858,7 +858,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2016_03_30.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -880,7 +880,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -889,7 +889,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2016_03_30.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -931,7 +931,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -970,7 +970,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -1003,7 +1003,7 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, **kwargs ): """ @@ -1042,7 +1042,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -1132,7 +1132,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -1199,8 +1199,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2016_03_30.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -1216,8 +1216,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2016_03_30.models.CachingTypes :ivar create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -1225,7 +1224,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2016_03_30.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1254,12 +1253,12 @@ def __init__( self, *, name: str, - vhd: "VirtualHardDisk", - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: "_models.VirtualHardDisk", + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, **kwargs ): @@ -1267,7 +1266,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2016_03_30.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -1283,8 +1282,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2016_03_30.models.CachingTypes :keyword create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -1292,7 +1290,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2016_03_30.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1315,8 +1313,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2016_03_30.models.OperatingSystemTypes """ @@ -1331,12 +1329,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2016_03_30.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -1421,9 +1419,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -1650,7 +1648,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -1732,9 +1730,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -1792,8 +1790,7 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual". :vartype mode: str or ~azure.mgmt.compute.v2016_03_30.models.UpgradeMode """ @@ -1804,7 +1801,7 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, **kwargs ): """ @@ -1812,8 +1809,7 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual". :paramtype mode: str or ~azure.mgmt.compute.v2016_03_30.models.UpgradeMode """ super(UpgradePolicy, self).__init__(**kwargs) @@ -1858,7 +1854,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -1980,8 +1976,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -2126,14 +2122,14 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -2220,8 +2216,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2399,7 +2395,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -2464,7 +2460,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -2601,8 +2597,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2639,7 +2635,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -2877,9 +2873,9 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, **kwargs ): """ @@ -2949,11 +2945,11 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -3013,7 +3009,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -3089,10 +3085,10 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, over_provision: Optional[bool] = None, **kwargs ): @@ -3223,7 +3219,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs ): """ @@ -3308,7 +3304,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -3389,10 +3385,10 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + subnet: Optional["_models.ApiEntityReference"] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -3445,7 +3441,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -3485,7 +3481,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -3525,7 +3521,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -3574,7 +3570,7 @@ def __init__( name: str, id: Optional[str] = None, primary: Optional[bool] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, **kwargs ): """ @@ -3609,7 +3605,7 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -3631,20 +3627,19 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2016_03_30.models.CachingTypes :ivar create_option: Required. Specifies how the virtual machines in the scale set should be created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2016_03_30.models.DiskCreateOptionTypes :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2016_03_30.models.OperatingSystemTypes :ivar image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before using it to attach to the Virtual Machine. If SourceImage is provided, the destination @@ -3672,10 +3667,10 @@ def __init__( self, *, name: str, - create_option: Union[str, "DiskCreateOptionTypes"], - caching: Optional[Union[str, "CachingTypes"]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + caching: Optional[Union[str, "_models.CachingTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, **kwargs ): @@ -3685,20 +3680,19 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2016_03_30.models.CachingTypes :keyword create_option: Required. Specifies how the virtual machines in the scale set should be created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2016_03_30.models.DiskCreateOptionTypes :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2016_03_30.models.OperatingSystemTypes :keyword image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before using it to attach to the Virtual Machine. If SourceImage is provided, the destination @@ -3779,9 +3773,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -3886,8 +3880,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetSkuScaleType """ @@ -3936,8 +3929,8 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, **kwargs ): """ @@ -4065,13 +4058,13 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -4271,11 +4264,11 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -4335,7 +4328,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -4377,10 +4370,10 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, **kwargs ): """ @@ -4481,7 +4474,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -4560,8 +4553,8 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -4606,7 +4599,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -4621,8 +4614,8 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :vartype protocol: str or ~azure.mgmt.compute.v2016_03_30.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault @@ -4642,14 +4635,14 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2016_03_30.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/__init__.py index 266148781f3e..fc77b1d80981 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/__init__.py @@ -16,6 +16,9 @@ from ._virtual_machine_scale_sets_operations import VirtualMachineScaleSetsOperations from ._virtual_machine_scale_set_vms_operations import VirtualMachineScaleSetVMsOperations +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__ = [ 'AvailabilitySetsOperations', 'VirtualMachineExtensionImagesOperations', @@ -27,3 +30,5 @@ 'VirtualMachineScaleSetsOperations', 'VirtualMachineScaleSetVMsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_availability_sets_operations.py index c5f9fbcc78db..d63f247fc1fa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,9 +78,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -91,18 +95,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -113,9 +115,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -127,18 +132,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -149,9 +152,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -161,20 +167,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -184,9 +188,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -197,18 +204,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -219,9 +224,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -233,51 +241,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -291,14 +295,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2016_03_30.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -310,11 +317,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -341,7 +350,7 @@ def delete( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: + ) -> Optional[_models.OperationStatusResponse]: """Delete an availability set. :param resource_group_name: The name of the resource group. @@ -353,13 +362,16 @@ def delete( :rtype: ~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request( @@ -368,11 +380,13 @@ def delete( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -413,13 +427,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_03_30.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -428,11 +445,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -471,13 +490,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -486,9 +508,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -497,9 +521,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -537,7 +563,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -549,13 +575,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -564,9 +593,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -575,9 +606,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -616,7 +649,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -631,13 +664,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -647,9 +683,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -659,9 +697,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_usage_operations.py index e6e753220fd1..1967ecae8f33 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_extension_images_operations.py index e0426846588f..0f0e2e575ff8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_extensions_operations.py index eb64d41a039c..36ae84af5f87 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,9 +129,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,18 +147,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -167,9 +170,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -182,61 +188,60 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -249,11 +254,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -284,9 +291,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -313,17 +320,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -331,20 +341,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -362,17 +379,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -385,11 +405,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -416,9 +438,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -445,17 +467,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -463,20 +488,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -495,14 +527,17 @@ def _delete_initial( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -512,11 +547,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -546,7 +583,7 @@ def begin_delete( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -569,35 +606,45 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -618,7 +665,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -634,13 +681,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -651,11 +701,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_images_operations.py index 6ca478a8bb6b..b76d304a53df 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_scale_set_vms_operations.py index f6e52ecb3411..d567e19a8124 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,6 +17,7 @@ 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 @@ -35,9 +36,12 @@ def build_reimage_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -50,18 +54,16 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -73,9 +75,12 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -88,18 +93,16 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -111,9 +114,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -126,18 +132,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -149,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -164,18 +171,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +192,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -202,18 +210,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -228,9 +234,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -242,24 +251,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -271,9 +278,12 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -286,18 +296,16 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -309,9 +317,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -324,18 +335,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -347,9 +356,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -362,42 +374,38 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( self, @@ -405,14 +413,17 @@ def _reimage_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_request_initial( @@ -422,11 +433,13 @@ def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,7 +469,7 @@ def begin_reimage( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -479,35 +492,45 @@ def begin_reimage( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -526,14 +549,17 @@ def _deallocate_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -543,11 +569,13 @@ def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -577,7 +605,7 @@ def begin_deallocate( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and releases the compute resources it uses. You are not billed for the compute resources of this virtual machine once it is deallocated. @@ -602,35 +630,45 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -649,14 +687,17 @@ def _delete_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -666,11 +707,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -700,7 +743,7 @@ def begin_delete( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -723,35 +766,45 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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( @@ -771,7 +824,7 @@ def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -785,13 +838,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -801,11 +857,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -833,7 +891,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -847,13 +905,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -863,11 +924,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -897,7 +960,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -921,13 +984,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -940,9 +1006,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -955,9 +1023,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -996,14 +1066,17 @@ def _power_off_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -1013,11 +1086,13 @@ def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1047,7 +1122,7 @@ def begin_power_off( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -1072,35 +1147,45 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1119,14 +1204,17 @@ def _restart_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -1136,11 +1224,13 @@ def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1170,7 +1260,7 @@ def begin_restart( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Restarts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1193,35 +1283,45 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1240,14 +1340,17 @@ def _start_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1257,11 +1360,13 @@ def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1291,7 +1396,7 @@ def begin_start( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Starts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1314,35 +1419,45 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_scale_sets_operations.py index 9987088a5c30..f2de784ff991 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,9 +80,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -93,18 +97,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -115,9 +117,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -129,18 +134,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -150,14 +153,17 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +175,18 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -194,14 +198,17 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -213,20 +220,18 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -239,9 +244,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -253,18 +261,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -274,9 +280,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -287,18 +296,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -307,9 +314,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -319,18 +329,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -341,9 +349,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -355,18 +366,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -376,14 +385,17 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -395,20 +407,18 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -420,14 +430,17 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -439,20 +452,18 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -464,14 +475,17 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -483,20 +497,18 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -508,14 +520,17 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -527,20 +542,18 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -553,9 +566,12 @@ def build_reimage_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -567,58 +583,57 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -630,11 +645,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -664,9 +681,9 @@ def begin_create_or_update( self, resource_group_name: str, name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -689,37 +706,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, name=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('VirtualMachineScaleSet', 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( @@ -737,14 +764,17 @@ def _delete_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -753,11 +783,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -786,7 +818,7 @@ def begin_delete( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a VM scale set. :param resource_group_name: The name of the resource group. @@ -807,34 +839,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -853,7 +895,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -865,13 +907,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -880,11 +925,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -909,17 +956,20 @@ def _deallocate_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -934,11 +984,13 @@ def _deallocate_initial( content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -966,9 +1018,9 @@ def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. @@ -995,37 +1047,47 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1042,17 +1104,20 @@ def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1064,11 +1129,13 @@ def _delete_instances_initial( content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1096,9 +1163,9 @@ def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1122,37 +1189,47 @@ def begin_delete_instances( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1171,7 +1248,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1183,13 +1260,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1198,11 +1278,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1228,7 +1310,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1240,13 +1322,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1255,9 +1340,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1266,9 +1353,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1305,7 +1394,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1317,13 +1406,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1331,9 +1423,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1341,9 +1435,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1382,7 +1478,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1397,13 +1493,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1413,9 +1512,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1425,9 +1526,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1464,17 +1567,20 @@ def _power_off_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1489,11 +1595,13 @@ def _power_off_initial( content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1521,9 +1629,9 @@ def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -1550,37 +1658,47 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1597,17 +1715,20 @@ def _restart_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1622,11 +1743,13 @@ def _restart_initial( content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1654,9 +1777,9 @@ def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1681,37 +1804,47 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1728,17 +1861,20 @@ def _start_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1753,11 +1889,13 @@ def _start_initial( content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1785,9 +1923,9 @@ def begin_start( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1812,37 +1950,47 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1859,17 +2007,20 @@ def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1881,11 +2032,13 @@ def _update_instances_initial( content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1913,9 +2066,9 @@ def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. @@ -1939,37 +2092,47 @@ def begin_update_instances( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1987,14 +2150,17 @@ def _reimage_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_request_initial( @@ -2003,11 +2169,13 @@ def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2036,7 +2204,7 @@ def begin_reimage( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2057,34 +2225,44 @@ def begin_reimage( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_sizes_operations.py index 1e77420edcba..fc19abb743fd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes for a subscription in a location. :param location: The location upon which virtual-machine-sizes is queried. @@ -98,13 +98,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -113,9 +116,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -124,9 +129,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machines_operations.py index 276c2eb4aa23..b2ace4ae8ddd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_03_30/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +37,12 @@ def build_get_extensions_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_get_extensions_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -74,14 +75,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -93,20 +97,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -118,14 +120,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,20 +142,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -163,9 +166,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,18 +183,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +205,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -215,20 +222,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -239,9 +244,12 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -253,18 +261,16 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -275,9 +281,12 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -289,18 +298,16 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -310,9 +317,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -323,18 +333,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -343,9 +351,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -355,18 +366,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -377,9 +386,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -391,18 +403,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -413,9 +423,12 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -427,18 +440,16 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -449,9 +460,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -463,18 +477,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -485,9 +497,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -499,18 +514,16 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -521,9 +534,12 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -535,42 +551,38 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2016_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2016_03_30.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_extensions( @@ -579,7 +591,7 @@ def get_extensions( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -593,13 +605,16 @@ def get_extensions( :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_get_extensions_request( @@ -609,11 +624,13 @@ def get_extensions( api_version=api_version, expand=expand, template_url=self.get_extensions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -638,17 +655,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -660,11 +680,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -692,9 +714,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -718,37 +740,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -765,17 +797,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -787,11 +822,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -821,9 +858,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -845,37 +882,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -893,14 +940,17 @@ def _delete_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -909,11 +959,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -942,7 +994,7 @@ def begin_delete( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to delete a virtual machine. :param resource_group_name: The name of the resource group. @@ -963,34 +1015,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -1010,28 +1072,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2016_03_30.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1041,11 +1106,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1071,14 +1138,17 @@ def _deallocate_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -1087,11 +1157,13 @@ def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1120,7 +1192,7 @@ def begin_deallocate( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses. @@ -1142,34 +1214,44 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1188,7 +1270,7 @@ def generalize( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.OperationStatusResponse": + ) -> _models.OperationStatusResponse: """Sets the state of the virtual machine to generalized. :param resource_group_name: The name of the resource group. @@ -1200,13 +1282,16 @@ def generalize( :rtype: ~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] request = build_generalize_request( @@ -1215,11 +1300,13 @@ def generalize( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1245,7 +1332,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1258,13 +1345,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1273,9 +1363,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1284,9 +1376,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1323,7 +1417,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1334,13 +1428,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1348,9 +1445,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1358,9 +1457,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1399,7 +1500,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1414,13 +1515,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_03_30.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1430,9 +1534,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1442,9 +1548,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1482,14 +1590,17 @@ def _power_off_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -1498,11 +1609,13 @@ def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1531,7 +1644,7 @@ def begin_power_off( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine. @@ -1553,34 +1666,44 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1598,14 +1721,17 @@ def _restart_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -1614,11 +1740,13 @@ def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1647,7 +1775,7 @@ def begin_restart( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to restart a virtual machine. :param resource_group_name: The name of the resource group. @@ -1668,34 +1796,44 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **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,14 +1851,17 @@ def _start_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1729,11 +1870,13 @@ def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1762,7 +1905,7 @@ def begin_start( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to start a virtual machine. :param resource_group_name: The name of the resource group. @@ -1783,34 +1926,44 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1828,14 +1981,17 @@ def _redeploy_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_redeploy_request_initial( @@ -1844,11 +2000,13 @@ def _redeploy_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1877,7 +2035,7 @@ def begin_redeploy( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine, moves it to a new node, and powers it back on. :param resource_group_name: The name of the resource group. @@ -1898,34 +2056,44 @@ def begin_redeploy( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-03-30") # type: 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-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/_compute_management_client.py index c764717c9c07..8e01b3c3feae 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/_compute_management_client.py @@ -85,18 +85,42 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/_compute_management_client.py index 618f7e8ca317..08b9153c54e8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/_compute_management_client.py @@ -85,18 +85,42 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/__init__.py index 1887a28bbe4c..60502558ebfb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/__init__.py @@ -19,6 +19,9 @@ from ._disks_operations import DisksOperations from ._snapshots_operations import SnapshotsOperations +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__ = [ 'AvailabilitySetsOperations', 'VirtualMachineExtensionImagesOperations', @@ -33,3 +36,5 @@ 'DisksOperations', 'SnapshotsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_availability_sets_operations.py index 5c8cafd19e98..8abde98679c0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,7 +120,7 @@ async def delete( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: + ) -> Optional[_models.OperationStatusResponse]: """Delete an availability set. :param resource_group_name: The name of the resource group. @@ -128,13 +132,16 @@ async def delete( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request( @@ -143,11 +150,13 @@ async def delete( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -176,7 +185,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -188,13 +197,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -203,11 +215,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -232,7 +246,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -242,13 +256,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -256,9 +273,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -266,9 +285,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -306,7 +327,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -318,13 +339,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -333,9 +357,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -344,9 +370,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -385,7 +413,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -400,13 +428,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +447,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -428,9 +461,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_disks_operations.py index 8141b9f1c2ea..c65d90b53f72 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -368,14 +402,17 @@ async def _delete_initial( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -417,7 +456,7 @@ async def begin_delete( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a disk. :param resource_group_name: The name of the resource group. @@ -440,34 +479,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -485,7 +534,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -496,13 +545,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -511,9 +563,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -522,9 +576,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -561,7 +617,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -570,13 +626,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -584,9 +643,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +655,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -633,17 +696,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -655,11 +721,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -687,9 +755,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -715,37 +783,47 @@ async def begin_grant_access( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -763,14 +841,17 @@ async def _revoke_access_initial( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_revoke_access_request_initial( @@ -779,11 +860,13 @@ async def _revoke_access_initial( disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -812,7 +895,7 @@ async def begin_revoke_access( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Revokes access to a disk. :param resource_group_name: The name of the resource group. @@ -835,34 +918,44 @@ async def begin_revoke_access( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_images_operations.py index 3e18b4ce2ffe..dcea48f35f8c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -131,37 +135,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -179,14 +193,17 @@ async def _delete_initial( resource_group_name: str, image_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -195,11 +212,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -228,7 +247,7 @@ async def begin_delete( resource_group_name: str, image_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes an Image. :param resource_group_name: The name of the resource group. @@ -249,34 +268,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -296,7 +325,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -310,13 +339,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -326,11 +358,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -356,7 +390,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -367,13 +401,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -382,9 +419,11 @@ def prepare_request(next_link=None): 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: @@ -393,9 +432,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -432,7 +473,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -442,13 +483,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +500,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -466,9 +512,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_snapshots_operations.py index cf4ce48c7106..825acf18e9d8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -324,13 +353,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -339,11 +371,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,14 +403,17 @@ async def _delete_initial( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -385,11 +422,13 @@ async def _delete_initial( snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -418,7 +457,7 @@ async def begin_delete( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a snapshot. :param resource_group_name: The name of the resource group. @@ -440,34 +479,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -485,7 +534,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -496,13 +545,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -511,9 +563,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -522,9 +576,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -561,7 +617,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -570,13 +626,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -584,9 +643,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +655,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -633,17 +696,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -655,11 +721,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -687,9 +755,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -714,37 +782,47 @@ async def begin_grant_access( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -762,14 +840,17 @@ async def _revoke_access_initial( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_revoke_access_request_initial( @@ -778,11 +859,13 @@ async def _revoke_access_initial( snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -811,7 +894,7 @@ async def begin_revoke_access( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Revokes access to a snapshot. :param resource_group_name: The name of the resource group. @@ -833,34 +916,44 @@ async def begin_revoke_access( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_usage_operations.py index d56caab494ea..0257617aeca1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_extension_images_operations.py index 4643cd129905..84192d11f2ed 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_extensions_operations.py index 39ca50df9f47..0f24962edbec 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -138,17 +142,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -156,20 +163,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -187,17 +201,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -210,11 +227,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,9 +260,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -270,17 +289,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -288,20 +310,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,14 +349,17 @@ async def _delete_initial( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -337,11 +369,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,7 +405,7 @@ async def begin_delete( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -394,35 +428,45 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -443,7 +487,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -459,13 +503,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -476,11 +523,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_images_operations.py index 2f50824f3d57..2874506e9943 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_scale_set_vms_operations.py index 4303c19e09e4..b8b2268ce17a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( self, @@ -53,14 +52,17 @@ async def _reimage_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_request_initial( @@ -70,11 +72,13 @@ async def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -104,7 +108,7 @@ async def begin_reimage( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -127,35 +131,45 @@ async def begin_reimage( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -174,14 +188,17 @@ async def _reimage_all_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_all_request_initial( @@ -191,11 +208,13 @@ async def _reimage_all_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -225,7 +244,7 @@ async def begin_reimage_all( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. This operation is only supported for managed disks. @@ -249,35 +268,45 @@ async def begin_reimage_all( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -296,14 +325,17 @@ async def _deallocate_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -313,11 +345,13 @@ async def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,7 +381,7 @@ async def begin_deallocate( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and releases the compute resources it uses. You are not billed for the compute resources of this virtual machine once it is deallocated. @@ -372,35 +406,45 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -419,14 +463,17 @@ async def _delete_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -436,11 +483,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +519,7 @@ async def begin_delete( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -493,35 +542,45 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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( @@ -541,7 +600,7 @@ async def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -555,13 +614,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -571,11 +633,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -603,7 +667,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -617,13 +681,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -633,11 +700,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -667,7 +736,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -687,13 +756,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -706,9 +778,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -721,9 +795,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -762,14 +838,17 @@ async def _power_off_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -779,11 +858,13 @@ async def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -813,7 +894,7 @@ async def begin_power_off( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -838,35 +919,45 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -885,14 +976,17 @@ async def _restart_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -902,11 +996,13 @@ async def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -936,7 +1032,7 @@ async def begin_restart( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Restarts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -959,35 +1055,45 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1006,14 +1112,17 @@ async def _start_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1023,11 +1132,13 @@ async def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1057,7 +1168,7 @@ async def begin_start( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Starts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1080,35 +1191,45 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_scale_sets_operations.py index 3e6df329fb84..c108864e0cfa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, name=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('VirtualMachineScaleSet', 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( @@ -180,14 +194,17 @@ async def _delete_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -196,11 +213,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -229,7 +248,7 @@ async def begin_delete( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a VM scale set. :param resource_group_name: The name of the resource group. @@ -250,34 +269,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -296,7 +325,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -308,13 +337,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -323,11 +355,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -352,17 +386,20 @@ async def _deallocate_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -377,11 +414,13 @@ async def _deallocate_initial( content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -409,9 +448,9 @@ async def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. @@ -438,37 +477,47 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -485,17 +534,20 @@ async def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # 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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -507,11 +559,13 @@ async def _delete_instances_initial( content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -539,9 +593,9 @@ async def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -565,37 +619,47 @@ async def begin_delete_instances( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -614,7 +678,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -626,13 +690,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -641,11 +708,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -671,7 +740,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -683,13 +752,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -698,9 +770,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -709,9 +783,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -748,7 +824,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -760,13 +836,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -774,9 +853,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -784,9 +865,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -825,7 +908,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -840,13 +923,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -856,9 +942,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -868,9 +956,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -907,17 +997,20 @@ async def _power_off_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -932,11 +1025,13 @@ async def _power_off_initial( content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -964,9 +1059,9 @@ async def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -993,37 +1088,47 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1040,17 +1145,20 @@ async def _restart_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1065,11 +1173,13 @@ async def _restart_initial( content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1097,9 +1207,9 @@ async def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1124,37 +1234,47 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1171,17 +1291,20 @@ async def _start_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1196,11 +1319,13 @@ async def _start_initial( content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1228,9 +1353,9 @@ async def begin_start( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1255,37 +1380,47 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1302,17 +1437,20 @@ async def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # 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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1324,11 +1462,13 @@ async def _update_instances_initial( content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1356,9 +1496,9 @@ async def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. @@ -1382,37 +1522,47 @@ async def begin_update_instances( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1430,14 +1580,17 @@ async def _reimage_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_request_initial( @@ -1446,11 +1599,13 @@ async def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1479,7 +1634,7 @@ async def begin_reimage( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1500,34 +1655,44 @@ async def begin_reimage( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1545,14 +1710,17 @@ async def _reimage_all_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_all_request_initial( @@ -1561,11 +1729,13 @@ async def _reimage_all_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1594,7 +1764,7 @@ async def begin_reimage_all( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This operation is only supported for managed disks. @@ -1616,34 +1786,44 @@ async def begin_reimage_all( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_sizes_operations.py index 2b736c0dffaa..bcbf3c7d17a6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes for a subscription in a location. :param location: The location upon which virtual-machine-sizes is queried. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machines_operations.py index bd6e2c9002f9..e9cb32ba5675 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_extensions( @@ -54,7 +53,7 @@ async def get_extensions( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -68,13 +67,16 @@ async def get_extensions( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_get_extensions_request( @@ -84,11 +86,13 @@ async def get_extensions( api_version=api_version, expand=expand, template_url=self.get_extensions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,17 +117,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -135,11 +142,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -167,9 +176,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -194,37 +203,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -241,17 +260,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -263,11 +285,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -297,9 +321,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -322,37 +346,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -370,14 +404,17 @@ async def _delete_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -419,7 +458,7 @@ async def begin_delete( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to delete a virtual machine. :param resource_group_name: The name of the resource group. @@ -440,34 +479,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -487,28 +536,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -518,11 +570,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -548,14 +602,17 @@ async def _convert_to_managed_disks_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_convert_to_managed_disks_request_initial( @@ -564,11 +621,13 @@ async def _convert_to_managed_disks_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -597,7 +656,7 @@ async def begin_convert_to_managed_disks( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation. @@ -619,34 +678,44 @@ async def begin_convert_to_managed_disks( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -664,14 +733,17 @@ async def _deallocate_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -680,11 +752,13 @@ async def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -713,7 +787,7 @@ async def begin_deallocate( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses. @@ -735,34 +809,44 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -781,7 +865,7 @@ async def generalize( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.OperationStatusResponse": + ) -> _models.OperationStatusResponse: """Sets the state of the virtual machine to generalized. :param resource_group_name: The name of the resource group. @@ -793,13 +877,16 @@ async def generalize( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] request = build_generalize_request( @@ -808,11 +895,13 @@ async def generalize( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -838,7 +927,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -851,13 +940,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -866,9 +958,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -877,9 +971,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +1012,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -927,13 +1023,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -941,9 +1040,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -951,9 +1052,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +1095,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1007,13 +1110,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1023,9 +1129,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1035,9 +1143,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1075,14 +1185,17 @@ async def _power_off_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -1091,11 +1204,13 @@ async def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1124,7 +1239,7 @@ async def begin_power_off( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine. @@ -1146,34 +1261,44 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1191,14 +1316,17 @@ async def _restart_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -1207,11 +1335,13 @@ async def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1240,7 +1370,7 @@ async def begin_restart( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to restart a virtual machine. :param resource_group_name: The name of the resource group. @@ -1261,34 +1391,44 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1306,14 +1446,17 @@ async def _start_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1322,11 +1465,13 @@ async def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1355,7 +1500,7 @@ async def begin_start( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to start a virtual machine. :param resource_group_name: The name of the resource group. @@ -1376,34 +1521,44 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1421,14 +1576,17 @@ async def _redeploy_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_redeploy_request_initial( @@ -1437,11 +1595,13 @@ async def _redeploy_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1470,7 +1630,7 @@ async def begin_redeploy( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine, moves it to a new node, and powers it back on. :param resource_group_name: The name of the resource group. @@ -1491,34 +1651,44 @@ async def begin_redeploy( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/__init__.py index d4037ab4a287..092e044e539d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/__init__.py @@ -135,7 +135,9 @@ VirtualMachineScaleSetSkuScaleType, VirtualMachineSizeTypes, ) - +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__ = [ 'AccessUri', 'AdditionalUnattendContent', @@ -263,3 +265,5 @@ 'VirtualMachineScaleSetSkuScaleType', 'VirtualMachineSizeTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/_compute_management_client_enums.py index 7319ce556728..3985c39ae133 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/_compute_management_client_enums.py @@ -7,16 +7,15 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -27,7 +26,7 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -38,7 +37,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COPY = "Copy" RESTORE = "Restore" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -51,21 +50,21 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ GENERALIZED = "Generalized" SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -73,7 +72,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -81,7 +80,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -89,7 +88,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. Possible values are: Standard_LRS or Premium_LRS. """ @@ -97,7 +96,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_LRS = "Standard_LRS" PREMIUM_LRS = "Premium_LRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -108,14 +107,14 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTOMATIC = "Automatic" MANUAL = "Manual" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. For more information about virtual machine sizes, see `Sizes for virtual machines `_. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/_models_py3.py index cde46a93b572..73d57333f88c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -52,7 +54,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2016_04_30_preview.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -73,7 +75,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -86,7 +88,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2016_04_30_preview.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -154,8 +156,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -333,10 +335,10 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, managed: Optional[bool] = None, **kwargs ): @@ -390,7 +392,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -502,8 +504,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore". :vartype create_option: str or ~azure.mgmt.compute.v2016_04_30_preview.models.DiskCreateOption :ivar storage_account_id: If createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in a @@ -535,16 +537,16 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, **kwargs ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore". + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore". :paramtype create_option: str or ~azure.mgmt.compute.v2016_04_30_preview.models.DiskCreateOption :keyword storage_account_id: If createOption is Import, the Azure Resource Manager identifier @@ -589,8 +591,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2016_04_30_preview.models.CachingTypes :ivar create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -598,7 +599,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2016_04_30_preview.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be @@ -629,13 +630,13 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ @@ -654,8 +655,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2016_04_30_preview.models.CachingTypes :keyword create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -663,7 +663,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2016_04_30_preview.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can @@ -729,7 +729,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -760,13 +760,13 @@ class Disk(Resource): :vartype location: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar account_type: the storage account type of the disk. Possible values include: - "Standard_LRS", "Premium_LRS". + :ivar account_type: the storage account type of the disk. Known values are: "Standard_LRS", + "Premium_LRS". :vartype account_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StorageAccountTypes :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -815,11 +815,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - creation_data: Optional["CreationData"] = None, + account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ @@ -827,11 +827,11 @@ def __init__( :paramtype location: str :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword account_type: the storage account type of the disk. Possible values include: - "Standard_LRS", "Premium_LRS". + :keyword account_type: the storage account type of the disk. Known values are: "Standard_LRS", + "Premium_LRS". :paramtype account_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StorageAccountTypes - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -879,8 +879,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -919,7 +919,7 @@ def __init__( self, *, name: Optional[str] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -957,7 +957,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -1003,11 +1003,11 @@ class DiskUpdate(ResourceUpdate): :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar account_type: the storage account type of the disk. Possible values include: - "Standard_LRS", "Premium_LRS". + :ivar account_type: the storage account type of the disk. Known values are: "Standard_LRS", + "Premium_LRS". :vartype account_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StorageAccountTypes - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes :ivar creation_data: disk source information. CreationData information cannot be changed after the disk has been created. @@ -1034,21 +1034,21 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - creation_data: Optional["CreationData"] = None, + account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword account_type: the storage account type of the disk. Possible values include: - "Standard_LRS", "Premium_LRS". + :keyword account_type: the storage account type of the disk. Known values are: "Standard_LRS", + "Premium_LRS". :paramtype account_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StorageAccountTypes - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes :keyword creation_data: disk source information. CreationData information cannot be changed after the disk has been created. @@ -1096,8 +1096,8 @@ def __init__( self, *, enabled: Optional[bool] = None, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -1124,7 +1124,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read". + :ivar access: Required. Known values are: "None", "Read". :vartype access: str or ~azure.mgmt.compute.v2016_04_30_preview.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -1143,12 +1143,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read". + :keyword access: Required. Known values are: "None", "Read". :paramtype access: str or ~azure.mgmt.compute.v2016_04_30_preview.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -1169,16 +1169,16 @@ class HardwareProfile(msrest.serialization.Model): machine sizes in an availability set `_ :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual - machine sizes for resizing `_. Possible values - include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", - "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", - "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_D1", - "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", - "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", - "Standard_D5_v2", "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", - "Standard_D15_v2", "Standard_DS1", "Standard_DS2", "Standard_DS3", "Standard_DS4", - "Standard_DS11", "Standard_DS12", "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", - "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", + machine sizes for resizing `_. Known values are: + "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", + "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", + "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_D1", "Standard_D2", + "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14", + "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", + "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", + "Standard_DS1", "Standard_DS2", "Standard_DS3", "Standard_DS4", "Standard_DS11", + "Standard_DS12", "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", + "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", "Standard_DS14_v2", "Standard_DS15_v2", "Standard_G1", "Standard_G2", "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", "Standard_GS4", "Standard_GS5". @@ -1192,7 +1192,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -1204,16 +1204,16 @@ def __init__( machine sizes in an availability set `_ :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual - machine sizes for resizing `_. Possible values - include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", - "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", - "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_D1", - "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", - "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", - "Standard_D5_v2", "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", - "Standard_D15_v2", "Standard_DS1", "Standard_DS2", "Standard_DS3", "Standard_DS4", - "Standard_DS11", "Standard_DS12", "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", - "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", + machine sizes for resizing `_. Known values are: + "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", + "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", + "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_D1", "Standard_D2", + "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14", + "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", + "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", "Standard_D15_v2", + "Standard_DS1", "Standard_DS2", "Standard_DS3", "Standard_DS4", "Standard_DS11", + "Standard_DS12", "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", + "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", "Standard_DS14_v2", "Standard_DS15_v2", "Standard_G1", "Standard_G2", "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", "Standard_GS4", "Standard_GS5". @@ -1273,8 +1273,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, **kwargs ): """ @@ -1311,8 +1311,7 @@ class ImageDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2016_04_30_preview.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1337,10 +1336,10 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, **kwargs ): @@ -1358,8 +1357,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2016_04_30_preview.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1441,7 +1439,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -1464,10 +1462,10 @@ class ImageOSDisk(msrest.serialization.Model): :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemStateTypes :ivar snapshot: The snapshot. @@ -1479,8 +1477,7 @@ class ImageOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2016_04_30_preview.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1506,23 +1503,22 @@ class ImageOSDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, **kwargs ): """ :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemStateTypes :keyword snapshot: The snapshot. @@ -1534,8 +1530,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2016_04_30_preview.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1668,8 +1663,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: "ImageOSDisk", - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: "_models.ImageOSDisk", + data_disks: Optional[List["_models.ImageDataDisk"]] = None, **kwargs ): """ @@ -1726,7 +1721,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -1748,7 +1743,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -1757,7 +1752,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -1798,7 +1793,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -1837,7 +1832,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -1877,7 +1872,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -1916,7 +1911,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -1949,7 +1944,7 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, **kwargs ): """ @@ -1988,7 +1983,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -2010,8 +2005,7 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", - "Premium_LRS". + values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StorageAccountTypes """ @@ -2025,14 +2019,14 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", + Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StorageAccountTypes @@ -2090,7 +2084,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -2157,8 +2151,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -2175,8 +2169,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2016_04_30_preview.models.CachingTypes :ivar create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -2184,7 +2177,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2016_04_30_preview.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be @@ -2214,22 +2207,22 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -2246,8 +2239,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2016_04_30_preview.models.CachingTypes :keyword create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -2255,7 +2247,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2016_04_30_preview.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can @@ -2282,8 +2274,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes """ @@ -2299,12 +2291,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes """ @@ -2391,9 +2383,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -2625,13 +2617,13 @@ class Snapshot(Resource): :vartype location: str :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar account_type: the storage account type of the disk. Possible values include: - "Standard_LRS", "Premium_LRS". + :ivar account_type: the storage account type of the disk. Known values are: "Standard_LRS", + "Premium_LRS". :vartype account_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StorageAccountTypes :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -2680,11 +2672,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - creation_data: Optional["CreationData"] = None, + account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ @@ -2692,11 +2684,11 @@ def __init__( :paramtype location: str :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword account_type: the storage account type of the disk. Possible values include: - "Standard_LRS", "Premium_LRS". + :keyword account_type: the storage account type of the disk. Known values are: "Standard_LRS", + "Premium_LRS". :paramtype account_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StorageAccountTypes - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -2745,7 +2737,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -2766,11 +2758,11 @@ class SnapshotUpdate(ResourceUpdate): :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar account_type: the storage account type of the disk. Possible values include: - "Standard_LRS", "Premium_LRS". + :ivar account_type: the storage account type of the disk. Known values are: "Standard_LRS", + "Premium_LRS". :vartype account_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StorageAccountTypes - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes :ivar creation_data: disk source information. CreationData information cannot be changed after the disk has been created. @@ -2797,21 +2789,21 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - creation_data: Optional["CreationData"] = None, + account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword account_type: the storage account type of the disk. Possible values include: - "Standard_LRS", "Premium_LRS". + :keyword account_type: the storage account type of the disk. Known values are: "Standard_LRS", + "Premium_LRS". :paramtype account_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StorageAccountTypes - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes :keyword creation_data: disk source information. CreationData information cannot be changed after the disk has been created. @@ -2872,7 +2864,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -2954,9 +2946,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -3041,8 +3033,7 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual". :vartype mode: str or ~azure.mgmt.compute.v2016_04_30_preview.models.UpgradeMode """ @@ -3053,7 +3044,7 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, **kwargs ): """ @@ -3061,8 +3052,7 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual". :paramtype mode: str or ~azure.mgmt.compute.v2016_04_30_preview.models.UpgradeMode """ super(UpgradePolicy, self).__init__(**kwargs) @@ -3107,7 +3097,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -3230,8 +3220,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -3379,14 +3369,14 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -3474,8 +3464,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -3653,7 +3643,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -3718,7 +3708,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -3855,8 +3845,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -3893,7 +3883,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -4131,9 +4121,9 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, **kwargs ): """ @@ -4205,11 +4195,11 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -4271,7 +4261,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -4359,11 +4349,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, over_provision: Optional[bool] = None, single_placement_group: Optional[bool] = None, **kwargs @@ -4421,11 +4411,10 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2016_04_30_preview.models.CachingTypes - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2016_04_30_preview.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be @@ -4455,11 +4444,11 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -4472,11 +4461,10 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2016_04_30_preview.models.CachingTypes - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2016_04_30_preview.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can @@ -4598,7 +4586,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs ): """ @@ -4683,7 +4671,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -4764,10 +4752,10 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + subnet: Optional["_models.ApiEntityReference"] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -4820,7 +4808,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -4860,7 +4848,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -4901,7 +4889,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -4921,8 +4909,7 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): """Describes the parameters of a ScaleSet managed disk. :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", - "Premium_LRS". + values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StorageAccountTypes """ @@ -4934,12 +4921,12 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", + Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.StorageAccountTypes @@ -4981,7 +4968,7 @@ def __init__( name: str, id: Optional[str] = None, primary: Optional[bool] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, **kwargs ): """ @@ -5016,7 +5003,7 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -5038,21 +5025,20 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2016_04_30_preview.models.CachingTypes :ivar create_option: Required. Specifies how the virtual machines in the scale set should be created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2016_04_30_preview.models.DiskCreateOptionTypes :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes :ivar image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before using it to attach to the Virtual Machine. If SourceImage is provided, the destination @@ -5082,13 +5068,13 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -5097,21 +5083,20 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2016_04_30_preview.models.CachingTypes :keyword create_option: Required. Specifies how the virtual machines in the scale set should be created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2016_04_30_preview.models.DiskCreateOptionTypes :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.OperatingSystemTypes :keyword image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before using it to attach to the Virtual Machine. If SourceImage is provided, the destination @@ -5197,9 +5182,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -5307,8 +5292,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetSkuScaleType """ @@ -5361,9 +5345,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -5496,13 +5480,13 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -5709,11 +5693,11 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -5780,7 +5764,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -5823,10 +5807,10 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, **kwargs ): """ @@ -5928,7 +5912,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -6007,8 +5991,8 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -6053,7 +6037,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -6068,8 +6052,8 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :vartype protocol: str or ~azure.mgmt.compute.v2016_04_30_preview.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault @@ -6089,14 +6073,14 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2016_04_30_preview.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/__init__.py index 1887a28bbe4c..60502558ebfb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/__init__.py @@ -19,6 +19,9 @@ from ._disks_operations import DisksOperations from ._snapshots_operations import SnapshotsOperations +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__ = [ 'AvailabilitySetsOperations', 'VirtualMachineExtensionImagesOperations', @@ -33,3 +36,5 @@ 'DisksOperations', 'SnapshotsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_availability_sets_operations.py index 518661bdfbeb..f49a31ece7d3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,9 +78,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -91,18 +95,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -113,9 +115,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -127,18 +132,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -147,9 +150,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -159,18 +165,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -180,9 +184,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +200,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -215,9 +220,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -229,51 +237,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_04_30_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.compute.v2016_04_30_preview.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -287,14 +291,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -306,11 +313,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,7 +346,7 @@ def delete( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: + ) -> Optional[_models.OperationStatusResponse]: """Delete an availability set. :param resource_group_name: The name of the resource group. @@ -349,13 +358,16 @@ def delete( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request( @@ -364,11 +376,13 @@ def delete( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -397,7 +411,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -409,13 +423,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -424,11 +441,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -453,7 +472,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -463,13 +482,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -477,9 +499,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -487,9 +511,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +553,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -539,13 +565,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +583,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -565,9 +596,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -606,7 +639,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -621,13 +654,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -637,9 +673,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -649,9 +687,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_disks_operations.py index 819a3932efc3..65886160caef 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -260,14 +266,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -279,20 +288,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -305,9 +312,12 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -319,58 +329,57 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_04_30_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.compute.v2016_04_30_preview.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -382,11 +391,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -416,9 +427,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -441,37 +452,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -488,17 +509,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -510,11 +534,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -544,9 +570,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -569,37 +595,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -618,7 +654,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -632,13 +668,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -647,11 +686,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -677,14 +718,17 @@ def _delete_initial( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -693,11 +737,13 @@ def _delete_initial( disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -726,7 +772,7 @@ def begin_delete( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a disk. :param resource_group_name: The name of the resource group. @@ -749,34 +795,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -794,7 +850,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -804,13 +860,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -819,9 +878,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -830,9 +891,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -869,7 +932,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -877,13 +940,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -891,9 +957,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -901,9 +969,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -940,17 +1010,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -962,11 +1035,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -994,9 +1069,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -1020,37 +1095,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1068,14 +1153,17 @@ def _revoke_access_initial( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_revoke_access_request_initial( @@ -1084,11 +1172,13 @@ def _revoke_access_initial( disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1117,7 +1207,7 @@ def begin_revoke_access( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Revokes access to a disk. :param resource_group_name: The name of the resource group. @@ -1140,34 +1230,44 @@ def begin_revoke_access( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_images_operations.py index a4eec140009c..db4b737f53b3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,9 +80,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -93,18 +97,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -117,9 +119,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -154,9 +157,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -167,18 +173,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +191,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -199,58 +206,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_04_30_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.compute.v2016_04_30_preview.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -262,11 +268,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -296,9 +304,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -319,37 +327,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -367,14 +385,17 @@ def _delete_initial( resource_group_name: str, image_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -383,11 +404,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -416,7 +439,7 @@ def begin_delete( resource_group_name: str, image_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes an Image. :param resource_group_name: The name of the resource group. @@ -437,34 +460,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -484,7 +517,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -498,13 +531,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -514,11 +550,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -544,7 +582,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -555,13 +593,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +611,11 @@ def prepare_request(next_link=None): 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: @@ -581,9 +624,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -620,7 +665,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -630,13 +675,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -644,9 +692,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -654,9 +704,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_snapshots_operations.py index c8f68a50e080..4eaf4731d950 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -260,14 +266,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -279,20 +288,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -305,9 +312,12 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -319,58 +329,57 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_04_30_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.compute.v2016_04_30_preview.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -382,11 +391,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -416,9 +427,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -440,37 +451,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -487,17 +508,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -509,11 +533,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -543,9 +569,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -567,37 +593,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -616,7 +652,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -629,13 +665,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -644,11 +683,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -674,14 +715,17 @@ def _delete_initial( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -690,11 +734,13 @@ def _delete_initial( snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -723,7 +769,7 @@ def begin_delete( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a snapshot. :param resource_group_name: The name of the resource group. @@ -745,34 +791,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -790,7 +846,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -801,13 +857,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -816,9 +875,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -827,9 +888,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -866,7 +929,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -875,13 +938,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -889,9 +955,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -899,9 +967,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -938,17 +1008,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -960,11 +1033,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -992,9 +1067,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -1017,37 +1092,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1065,14 +1150,17 @@ def _revoke_access_initial( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_revoke_access_request_initial( @@ -1081,11 +1169,13 @@ def _revoke_access_initial( snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1114,7 +1204,7 @@ def begin_revoke_access( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Revokes access to a snapshot. :param resource_group_name: The name of the resource group. @@ -1136,34 +1226,44 @@ def begin_revoke_access( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_usage_operations.py index e7bacf88c419..1ec84fbd561c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -98,13 +98,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -113,9 +116,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -124,9 +129,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_extension_images_operations.py index 76731d92c0ad..23b19f4a1f20 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_04_30_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.compute.v2016_04_30_preview.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_extensions_operations.py index 729e2b1bc7ec..644b7a446908 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,9 +129,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,18 +147,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -167,9 +170,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -182,61 +188,60 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_04_30_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.compute.v2016_04_30_preview.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -249,11 +254,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -284,9 +291,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -314,17 +321,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -332,20 +342,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -363,17 +380,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -386,11 +406,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -417,9 +439,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -446,17 +468,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -464,20 +489,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -496,14 +528,17 @@ def _delete_initial( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -513,11 +548,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -547,7 +584,7 @@ def begin_delete( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -570,35 +607,45 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -619,7 +666,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -635,13 +682,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -652,11 +702,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_images_operations.py index 16fc4c634496..b72731825d64 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_04_30_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.compute.v2016_04_30_preview.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_scale_set_vms_operations.py index 7af2439ab5ca..a403848f4487 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,6 +17,7 @@ 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 @@ -35,9 +36,12 @@ def build_reimage_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -50,18 +54,16 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -73,9 +75,12 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -88,18 +93,16 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -111,9 +114,12 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -126,18 +132,16 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -149,9 +153,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -164,18 +171,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +192,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -202,18 +210,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +231,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -240,18 +249,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -266,9 +273,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -280,24 +290,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -309,9 +317,12 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -324,18 +335,16 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -347,9 +356,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -362,18 +374,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -385,9 +395,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -400,42 +413,38 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_04_30_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.compute.v2016_04_30_preview.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( self, @@ -443,14 +452,17 @@ def _reimage_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_request_initial( @@ -460,11 +472,13 @@ def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -494,7 +508,7 @@ def begin_reimage( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -517,35 +531,45 @@ def begin_reimage( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -564,14 +588,17 @@ def _reimage_all_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_all_request_initial( @@ -581,11 +608,13 @@ def _reimage_all_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -615,7 +644,7 @@ def begin_reimage_all( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. This operation is only supported for managed disks. @@ -639,35 +668,45 @@ def begin_reimage_all( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -686,14 +725,17 @@ def _deallocate_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -703,11 +745,13 @@ def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -737,7 +781,7 @@ def begin_deallocate( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and releases the compute resources it uses. You are not billed for the compute resources of this virtual machine once it is deallocated. @@ -762,35 +806,45 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -809,14 +863,17 @@ def _delete_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -826,11 +883,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -860,7 +919,7 @@ def begin_delete( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -883,35 +942,45 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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( @@ -931,7 +1000,7 @@ def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -945,13 +1014,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -961,11 +1033,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -993,7 +1067,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1007,13 +1081,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1023,11 +1100,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1057,7 +1136,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1077,13 +1156,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1096,9 +1178,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1111,9 +1195,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1152,14 +1238,17 @@ def _power_off_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -1169,11 +1258,13 @@ def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1203,7 +1294,7 @@ def begin_power_off( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -1228,35 +1319,45 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1275,14 +1376,17 @@ def _restart_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -1292,11 +1396,13 @@ def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1326,7 +1432,7 @@ def begin_restart( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Restarts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1349,35 +1455,45 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1396,14 +1512,17 @@ def _start_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1413,11 +1532,13 @@ def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1447,7 +1568,7 @@ def begin_start( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Starts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1470,35 +1591,45 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_scale_sets_operations.py index d6861be7b29b..c3f2759beebb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,9 +80,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -93,18 +97,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -115,9 +117,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -129,18 +134,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -150,14 +153,17 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +175,18 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -194,14 +198,17 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -213,20 +220,18 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -239,9 +244,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -253,18 +261,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -274,9 +280,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -287,18 +296,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -307,9 +314,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -319,18 +329,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -341,9 +349,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -355,18 +366,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -376,14 +385,17 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -395,20 +407,18 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -420,14 +430,17 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -439,20 +452,18 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -464,14 +475,17 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -483,20 +497,18 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -508,14 +520,17 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -527,20 +542,18 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -553,9 +566,12 @@ def build_reimage_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -567,18 +583,16 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -589,9 +603,12 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -603,58 +620,57 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -666,11 +682,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -700,9 +718,9 @@ def begin_create_or_update( self, resource_group_name: str, name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -725,37 +743,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, name=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('VirtualMachineScaleSet', 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( @@ -773,14 +801,17 @@ def _delete_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -789,11 +820,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -822,7 +855,7 @@ def begin_delete( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a VM scale set. :param resource_group_name: The name of the resource group. @@ -843,34 +876,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -889,7 +932,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -901,13 +944,16 @@ def get( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -916,11 +962,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -945,17 +993,20 @@ def _deallocate_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -970,11 +1021,13 @@ def _deallocate_initial( content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1002,9 +1055,9 @@ def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. @@ -1031,37 +1084,47 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1078,17 +1141,20 @@ def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # 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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1100,11 +1166,13 @@ def _delete_instances_initial( content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1132,9 +1200,9 @@ def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1158,37 +1226,47 @@ def begin_delete_instances( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1207,7 +1285,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1219,13 +1297,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1234,11 +1315,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1264,7 +1347,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1276,13 +1359,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1291,9 +1377,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1302,9 +1390,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1341,7 +1431,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1353,13 +1443,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1367,9 +1460,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1377,9 +1472,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1418,7 +1515,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1433,13 +1530,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1449,9 +1549,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1461,9 +1563,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1500,17 +1604,20 @@ def _power_off_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1525,11 +1632,13 @@ def _power_off_initial( content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1557,9 +1666,9 @@ def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -1586,37 +1695,47 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1633,17 +1752,20 @@ def _restart_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1658,11 +1780,13 @@ def _restart_initial( content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1690,9 +1814,9 @@ def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1717,37 +1841,47 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1764,17 +1898,20 @@ def _start_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1789,11 +1926,13 @@ def _start_initial( content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1821,9 +1960,9 @@ def begin_start( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1848,37 +1987,47 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1895,17 +2044,20 @@ def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # 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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1917,11 +2069,13 @@ def _update_instances_initial( content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1949,9 +2103,9 @@ def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. @@ -1975,37 +2129,47 @@ def begin_update_instances( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2023,14 +2187,17 @@ def _reimage_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_request_initial( @@ -2039,11 +2206,13 @@ def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2072,7 +2241,7 @@ def begin_reimage( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2093,34 +2262,44 @@ def begin_reimage( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2138,14 +2317,17 @@ def _reimage_all_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_all_request_initial( @@ -2154,11 +2336,13 @@ def _reimage_all_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2187,7 +2371,7 @@ def begin_reimage_all( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This operation is only supported for managed disks. @@ -2209,34 +2393,44 @@ def begin_reimage_all( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_sizes_operations.py index aab0aac6e81e..f79b512c9c4f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2016_04_30_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.compute.v2016_04_30_preview.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes for a subscription in a location. :param location: The location upon which virtual-machine-sizes is queried. @@ -98,13 +98,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -113,9 +116,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -124,9 +129,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machines_operations.py index 0e94d7897290..32f51dfcbc5d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2016_04_30_preview/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +37,12 @@ def build_get_extensions_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_get_extensions_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -74,14 +75,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -93,20 +97,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -118,14 +120,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,20 +142,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -163,9 +166,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,18 +183,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +205,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -215,20 +222,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -239,9 +244,12 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -253,18 +261,16 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -275,9 +281,12 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -289,18 +298,16 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -311,9 +318,12 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -325,18 +335,16 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -346,9 +354,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -359,18 +370,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -379,9 +388,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -391,18 +403,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -413,9 +423,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -427,18 +440,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -449,9 +460,12 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -463,18 +477,16 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -485,9 +497,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -499,18 +514,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -521,9 +534,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -535,18 +551,16 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -557,9 +571,12 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + _headers = case_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-04-30-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -571,42 +588,38 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2016_04_30_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.compute.v2016_04_30_preview.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_extensions( @@ -615,7 +628,7 @@ def get_extensions( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -629,13 +642,16 @@ def get_extensions( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_get_extensions_request( @@ -645,11 +661,13 @@ def get_extensions( api_version=api_version, expand=expand, template_url=self.get_extensions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -674,17 +692,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -696,11 +717,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -728,9 +751,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -755,37 +778,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -802,17 +835,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -824,11 +860,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -858,9 +896,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -883,37 +921,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-04-30-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -931,14 +979,17 @@ def _delete_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -947,11 +998,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -980,7 +1033,7 @@ def begin_delete( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to delete a virtual machine. :param resource_group_name: The name of the resource group. @@ -1001,34 +1054,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -1048,28 +1111,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1079,11 +1145,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,14 +1177,17 @@ def _convert_to_managed_disks_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_convert_to_managed_disks_request_initial( @@ -1125,11 +1196,13 @@ def _convert_to_managed_disks_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1158,7 +1231,7 @@ def begin_convert_to_managed_disks( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation. @@ -1180,34 +1253,44 @@ def begin_convert_to_managed_disks( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1225,14 +1308,17 @@ def _deallocate_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -1241,11 +1327,13 @@ def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1274,7 +1362,7 @@ def begin_deallocate( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses. @@ -1296,34 +1384,44 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1342,7 +1440,7 @@ def generalize( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.OperationStatusResponse": + ) -> _models.OperationStatusResponse: """Sets the state of the virtual machine to generalized. :param resource_group_name: The name of the resource group. @@ -1354,13 +1452,16 @@ def generalize( :rtype: ~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] request = build_generalize_request( @@ -1369,11 +1470,13 @@ def generalize( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1399,7 +1502,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1412,13 +1515,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1427,9 +1533,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1438,9 +1546,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1477,7 +1587,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1488,13 +1598,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1502,9 +1615,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1512,9 +1627,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1553,7 +1670,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1568,13 +1685,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2016_04_30_preview.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1584,9 +1704,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1596,9 +1718,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1636,14 +1760,17 @@ def _power_off_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -1652,11 +1779,13 @@ def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1685,7 +1814,7 @@ def begin_power_off( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine. @@ -1707,34 +1836,44 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1752,14 +1891,17 @@ def _restart_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -1768,11 +1910,13 @@ def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1801,7 +1945,7 @@ def begin_restart( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to restart a virtual machine. :param resource_group_name: The name of the resource group. @@ -1822,34 +1966,44 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1867,14 +2021,17 @@ def _start_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1883,11 +2040,13 @@ def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1916,7 +2075,7 @@ def begin_start( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to start a virtual machine. :param resource_group_name: The name of the resource group. @@ -1937,34 +2096,44 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1982,14 +2151,17 @@ def _redeploy_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_redeploy_request_initial( @@ -1998,11 +2170,13 @@ def _redeploy_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2031,7 +2205,7 @@ def begin_redeploy( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine, moves it to a new node, and powers it back on. :param resource_group_name: The name of the resource group. @@ -2052,34 +2226,44 @@ def begin_redeploy( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2016_04_30_preview.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2016-04-30-preview") # type: 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-04-30-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/__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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_compute_management_client.py index 9c43111790ab..4708faa3bb63 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_compute_management_client.py @@ -97,22 +97,54 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.resource_skus = ResourceSkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/_compute_management_client.py index 53277b921951..93fb3d48b5cb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/_compute_management_client.py @@ -98,22 +98,54 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.resource_skus = ResourceSkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/__init__.py index e754e54122d1..6b954038534d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/__init__.py @@ -23,6 +23,9 @@ from ._snapshots_operations import SnapshotsOperations from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations +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__ = [ 'AvailabilitySetsOperations', 'VirtualMachineExtensionImagesOperations', @@ -41,3 +44,5 @@ 'SnapshotsOperations', 'VirtualMachineRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_availability_sets_operations.py index 0062a3d6da30..e142c7687f06 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,7 +120,7 @@ async def delete( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: + ) -> Optional[_models.OperationStatusResponse]: """Delete an availability set. :param resource_group_name: The name of the resource group. @@ -128,13 +132,16 @@ async def delete( :rtype: ~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request( @@ -143,11 +150,13 @@ async def delete( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -176,7 +185,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -188,13 +197,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -203,11 +215,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,7 +247,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -246,13 +260,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -261,9 +278,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -272,9 +291,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -312,7 +333,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -324,13 +345,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -339,9 +363,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -350,9 +376,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -391,7 +419,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -406,13 +434,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +453,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -434,9 +467,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_disks_operations.py index 9aac78f83a5b..5df2f9ed5c35 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -368,14 +402,17 @@ async def _delete_initial( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -417,7 +456,7 @@ async def begin_delete( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a disk. :param resource_group_name: The name of the resource group. @@ -440,34 +479,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -485,7 +534,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -496,13 +545,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -511,9 +563,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -522,9 +576,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -561,7 +617,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -570,13 +626,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -584,9 +643,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +655,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -633,17 +696,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -655,11 +721,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -687,9 +755,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -714,37 +782,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -762,14 +840,17 @@ async def _revoke_access_initial( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_revoke_access_request_initial( @@ -778,11 +859,13 @@ async def _revoke_access_initial( disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -811,7 +894,7 @@ async def begin_revoke_access( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Revokes access to a disk. :param resource_group_name: The name of the resource group. @@ -834,34 +917,44 @@ async def begin_revoke_access( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_images_operations.py index e372b508ef72..374ad423a7a0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -178,14 +192,17 @@ async def _delete_initial( resource_group_name: str, image_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -194,11 +211,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -227,7 +246,7 @@ async def begin_delete( resource_group_name: str, image_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes an Image. :param resource_group_name: The name of the resource group. @@ -248,34 +267,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -295,7 +324,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -309,13 +338,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -325,11 +357,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -355,7 +389,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -366,13 +400,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -381,9 +418,11 @@ def prepare_request(next_link=None): 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: @@ -392,9 +431,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -431,7 +472,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -441,13 +482,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -455,9 +499,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -465,9 +511,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_resource_skus_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_resource_skus_operations.py index 459418aa2881..1422b8a416d0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_resource_skus_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_resource_skus_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ResourceSkusOperations: - """ResourceSkusOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`resource_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.ResourceSkusResult"]: + ) -> AsyncIterable[_models.ResourceSkusResult]: """Gets the list of Microsoft.Compute SKUs available for your Subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -57,13 +56,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.ResourceSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -71,9 +73,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -81,9 +85,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_snapshots_operations.py index 0c5059eec696..a5a35fb880a2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -370,14 +404,17 @@ async def _delete_initial( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -419,7 +458,7 @@ async def begin_delete( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a snapshot. :param resource_group_name: The name of the resource group. @@ -442,34 +481,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -487,7 +536,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -498,13 +547,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -513,9 +565,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -524,9 +578,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -563,7 +619,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -572,13 +628,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -586,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -596,9 +657,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -635,17 +698,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -657,11 +723,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -689,9 +757,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -716,37 +784,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -764,14 +842,17 @@ async def _revoke_access_initial( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_revoke_access_request_initial( @@ -780,11 +861,13 @@ async def _revoke_access_initial( snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -813,7 +896,7 @@ async def begin_revoke_access( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Revokes access to a snapshot. :param resource_group_name: The name of the resource group. @@ -836,34 +919,44 @@ async def begin_revoke_access( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_usage_operations.py index 4b1d8ce30254..e20803df72a1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_extension_images_operations.py index 82ad3986ff49..f46db3e24f6b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_extensions_operations.py index d83e94f5694d..c510e05d063b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -319,14 +348,17 @@ async def _delete_initial( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -370,7 +404,7 @@ async def begin_delete( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -393,35 +427,45 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -442,7 +486,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -458,13 +502,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -475,11 +522,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_images_operations.py index 8e3efe0742ca..4bdd8159a384 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_run_commands_operations.py index d8be7e1bfd9b..5bc6643f5a95 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_run_commands_operations.py @@ -15,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 @@ -24,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,7 +135,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -141,13 +147,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -156,11 +165,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_set_extensions_operations.py index ee4e11b5a752..734687915986 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -190,14 +204,17 @@ async def _delete_initial( vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -207,11 +224,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,7 +260,7 @@ async def begin_delete( vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -264,35 +283,45 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -313,7 +342,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -329,13 +358,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -346,11 +378,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -377,7 +411,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -391,13 +425,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -407,9 +444,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -419,9 +458,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 545fefa0e3ee..69ec00c86314 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,40 +25,41 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -99,7 +103,7 @@ async def begin_cancel( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Cancels the current virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -120,34 +124,44 @@ async def begin_cancel( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -165,14 +179,17 @@ async def _start_os_upgrade_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_os_upgrade_request_initial( @@ -181,11 +198,13 @@ async def _start_os_upgrade_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -214,7 +233,7 @@ async def begin_start_os_upgrade( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Starts a rolling upgrade to move all virtual machine scale set instances to the latest available Platform Image OS version. Instances which are already running the latest available OS version are not affected. @@ -237,34 +256,44 @@ async def begin_start_os_upgrade( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -283,7 +312,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -295,13 +324,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2017_03_30.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -310,11 +342,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_set_vms_operations.py index a88e985ee921..e7e81ed4e87d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( self, @@ -53,14 +52,17 @@ async def _reimage_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_request_initial( @@ -70,11 +72,13 @@ async def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -104,7 +108,7 @@ async def begin_reimage( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -127,35 +131,45 @@ async def begin_reimage( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -174,14 +188,17 @@ async def _reimage_all_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_all_request_initial( @@ -191,11 +208,13 @@ async def _reimage_all_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -225,7 +244,7 @@ async def begin_reimage_all( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. This operation is only supported for managed disks. @@ -249,35 +268,45 @@ async def begin_reimage_all( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -296,14 +325,17 @@ async def _deallocate_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -313,11 +345,13 @@ async def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,7 +381,7 @@ async def begin_deallocate( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and releases the compute resources it uses. You are not billed for the compute resources of this virtual machine once it is deallocated. @@ -372,35 +406,45 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -419,14 +463,17 @@ async def _delete_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -436,11 +483,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +519,7 @@ async def begin_delete( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -493,35 +542,45 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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( @@ -541,7 +600,7 @@ async def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -555,13 +614,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -571,11 +633,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -603,7 +667,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -617,13 +681,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -633,11 +700,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -667,7 +736,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -691,13 +760,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -710,9 +782,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -725,9 +799,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -766,14 +842,17 @@ async def _power_off_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -783,11 +862,13 @@ async def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,7 +898,7 @@ async def begin_power_off( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -842,35 +923,45 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -889,14 +980,17 @@ async def _restart_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -906,11 +1000,13 @@ async def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -940,7 +1036,7 @@ async def begin_restart( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Restarts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -963,35 +1059,45 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1010,14 +1116,17 @@ async def _start_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1027,11 +1136,13 @@ async def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1061,7 +1172,7 @@ async def begin_start( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Starts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1084,35 +1195,45 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_sets_operations.py index 5d9c230aecfa..cc232cf91db5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -231,9 +250,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -304,14 +333,17 @@ async def _delete_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -353,7 +387,7 @@ async def begin_delete( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a VM scale set. :param resource_group_name: The name of the resource group. @@ -374,34 +408,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -420,7 +464,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -432,13 +476,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -447,11 +494,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -476,17 +525,20 @@ async def _deallocate_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -501,11 +553,13 @@ async def _deallocate_initial( content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -533,9 +587,9 @@ async def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. @@ -562,37 +616,47 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -609,17 +673,20 @@ async def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -631,11 +698,13 @@ async def _delete_instances_initial( content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -663,9 +732,9 @@ async def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -689,37 +758,47 @@ async def begin_delete_instances( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -738,7 +817,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -750,13 +829,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -765,11 +847,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -795,7 +879,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -807,13 +891,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -822,9 +909,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -833,9 +922,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -872,7 +963,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -884,13 +975,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -898,9 +992,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -908,9 +1004,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +1047,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -964,13 +1062,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -980,9 +1081,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -992,9 +1095,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1031,17 +1136,20 @@ async def _power_off_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1056,11 +1164,13 @@ async def _power_off_initial( content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1088,9 +1198,9 @@ async def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -1117,37 +1227,47 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1164,17 +1284,20 @@ async def _restart_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1189,11 +1312,13 @@ async def _restart_initial( content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1221,9 +1346,9 @@ async def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1248,37 +1373,47 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1295,17 +1430,20 @@ async def _start_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1320,11 +1458,13 @@ async def _start_initial( content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1352,9 +1492,9 @@ async def begin_start( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1379,37 +1519,47 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1426,17 +1576,20 @@ async def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # 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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1448,11 +1601,13 @@ async def _update_instances_initial( content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1480,9 +1635,9 @@ async def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. @@ -1506,37 +1661,47 @@ async def begin_update_instances( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1553,17 +1718,20 @@ async def _reimage_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1578,11 +1746,13 @@ async def _reimage_initial( content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1610,9 +1780,9 @@ async def begin_reimage( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1637,37 +1807,47 @@ async def begin_reimage( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1684,17 +1864,20 @@ async def _reimage_all_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1709,11 +1892,13 @@ async def _reimage_all_initial( content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1741,9 +1926,9 @@ async def begin_reimage_all( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This operation is only supported for managed disks. @@ -1769,37 +1954,47 @@ async def begin_reimage_all( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_sizes_operations.py index b4fcce3c31be..acbf386e53b0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes for a subscription in a location. :param location: The location upon which virtual-machine-sizes is queried. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machines_operations.py index db1f52b054dc..593a2e574bf1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_extensions( @@ -54,7 +53,7 @@ async def get_extensions( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -68,13 +67,16 @@ async def get_extensions( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_get_extensions_request( @@ -84,11 +86,13 @@ async def get_extensions( api_version=api_version, expand=expand, template_url=self.get_extensions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -114,7 +118,7 @@ def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -126,13 +130,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -141,9 +148,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -152,9 +161,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -191,17 +202,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -213,11 +227,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -245,9 +261,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -271,37 +287,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -318,17 +344,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -340,11 +369,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -374,9 +405,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -399,37 +430,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -447,14 +488,17 @@ async def _delete_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -463,11 +507,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +542,7 @@ async def begin_delete( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to delete a virtual machine. :param resource_group_name: The name of the resource group. @@ -517,34 +563,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -564,28 +620,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -595,11 +654,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -626,7 +687,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -638,13 +699,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -653,11 +717,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -683,14 +749,17 @@ async def _convert_to_managed_disks_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_convert_to_managed_disks_request_initial( @@ -699,11 +768,13 @@ async def _convert_to_managed_disks_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -732,7 +803,7 @@ async def begin_convert_to_managed_disks( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation. @@ -754,34 +825,44 @@ async def begin_convert_to_managed_disks( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -799,14 +880,17 @@ async def _deallocate_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -815,11 +899,13 @@ async def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -848,7 +934,7 @@ async def begin_deallocate( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses. @@ -870,34 +956,44 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -916,7 +1012,7 @@ async def generalize( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.OperationStatusResponse": + ) -> _models.OperationStatusResponse: """Sets the state of the virtual machine to generalized. :param resource_group_name: The name of the resource group. @@ -928,13 +1024,16 @@ async def generalize( :rtype: ~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] request = build_generalize_request( @@ -943,11 +1042,13 @@ async def generalize( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -973,7 +1074,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -986,13 +1087,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1001,9 +1105,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1012,9 +1118,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1051,7 +1159,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1062,13 +1170,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1076,9 +1187,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1086,9 +1199,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1127,7 +1242,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1142,13 +1257,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1158,9 +1276,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1170,9 +1290,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1210,14 +1332,17 @@ async def _power_off_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -1226,11 +1351,13 @@ async def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1259,7 +1386,7 @@ async def begin_power_off( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine. @@ -1281,34 +1408,44 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1326,14 +1463,17 @@ async def _restart_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -1342,11 +1482,13 @@ async def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1375,7 +1517,7 @@ async def begin_restart( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to restart a virtual machine. :param resource_group_name: The name of the resource group. @@ -1396,34 +1538,44 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1441,14 +1593,17 @@ async def _start_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1457,11 +1612,13 @@ async def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1490,7 +1647,7 @@ async def begin_start( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to start a virtual machine. :param resource_group_name: The name of the resource group. @@ -1511,34 +1668,44 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1556,14 +1723,17 @@ async def _redeploy_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_redeploy_request_initial( @@ -1572,11 +1742,13 @@ async def _redeploy_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1605,7 +1777,7 @@ async def begin_redeploy( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine, moves it to a new node, and powers it back on. :param resource_group_name: The name of the resource group. @@ -1626,34 +1798,44 @@ async def begin_redeploy( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1671,14 +1853,17 @@ async def _perform_maintenance_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_perform_maintenance_request_initial( @@ -1687,11 +1872,13 @@ async def _perform_maintenance_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1720,7 +1907,7 @@ async def begin_perform_maintenance( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to perform maintenance on a virtual machine. :param resource_group_name: The name of the resource group. @@ -1741,34 +1928,44 @@ async def begin_perform_maintenance( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1785,18 +1982,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1808,11 +2008,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1840,11 +2042,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -1853,7 +2055,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2017_03_30.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1870,36 +2072,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_03_30.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/__init__.py index 0685ae6245d9..0cdb4df12bca 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/__init__.py @@ -174,7 +174,9 @@ VirtualMachineScaleSetSkuScaleType, VirtualMachineSizeTypes, ) - +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__ = [ 'AccessUri', 'AdditionalUnattendContent', @@ -341,3 +343,5 @@ 'VirtualMachineScaleSetSkuScaleType', 'VirtualMachineSizeTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_compute_management_client_enums.py index e3a676bc30d3..07593881ade5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_compute_management_client_enums.py @@ -7,16 +7,15 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -27,7 +26,7 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -37,7 +36,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): IMPORT_ENUM = "Import" COPY = "Copy" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -50,7 +49,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -59,7 +58,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -68,21 +67,21 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ GENERALIZED = "Generalized" SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -90,7 +89,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ @@ -98,21 +97,21 @@ class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, MANUAL = "Manual" NONE = "None" -class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for restriction. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -121,7 +120,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -129,7 +128,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -137,7 +136,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. Possible values are: Standard_LRS or Premium_LRS. """ @@ -145,7 +144,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_LRS = "Standard_LRS" PREMIUM_LRS = "Premium_LRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -157,14 +156,14 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. For more information about virtual machine sizes, see `Sizes for virtual machines `_. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_models_py3.py index 49ff5bb9326d..b27ac114a2cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -52,7 +54,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2017_03_30.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -73,7 +75,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -86,7 +88,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2017_03_30.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -154,8 +156,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -330,10 +332,10 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -383,7 +385,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -495,8 +497,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy". :vartype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOption :ivar storage_account_id: If createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in a @@ -527,16 +529,16 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, **kwargs ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy". + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy". :paramtype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOption :keyword storage_account_id: If createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in @@ -579,8 +581,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes :ivar create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -588,7 +589,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -618,13 +619,13 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ @@ -643,8 +644,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes :keyword create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -652,7 +652,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -717,7 +717,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -756,7 +756,7 @@ class Disk(Resource): :vartype zones: list[str] :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -804,12 +804,12 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - creation_data: Optional["CreationData"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ @@ -821,7 +821,7 @@ def __init__( :paramtype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku :keyword zones: The Logical zone list for Disk. :paramtype zones: list[str] - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -867,8 +867,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -910,8 +910,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -954,7 +954,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -975,7 +975,7 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS". :vartype name: str or ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -993,11 +993,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "StorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS". :paramtype name: str or ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes """ super(DiskSku, self).__init__(**kwargs) @@ -1023,7 +1023,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, **kwargs ): """ @@ -1044,7 +1044,7 @@ class DiskUpdate(ResourceUpdate): :vartype tags: dict[str, str] :ivar sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -1067,10 +1067,10 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ @@ -1078,7 +1078,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. :paramtype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -1118,8 +1118,8 @@ def __init__( self, *, enabled: Optional[bool] = None, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -1145,7 +1145,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read". + :ivar access: Required. Known values are: "None", "Read". :vartype access: str or ~azure.mgmt.compute.v2017_03_30.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -1164,12 +1164,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read". + :keyword access: Required. Known values are: "None", "Read". :paramtype access: str or ~azure.mgmt.compute.v2017_03_30.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -1192,8 +1192,8 @@ class HardwareProfile(msrest.serialization.Model): :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -1222,7 +1222,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -1236,8 +1236,8 @@ def __init__( :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -1311,8 +1311,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, **kwargs ): """ @@ -1349,16 +1349,14 @@ class ImageDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", - "Premium_LRS". + values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes """ @@ -1381,12 +1379,12 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ @@ -1403,15 +1401,14 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", + Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes @@ -1492,7 +1489,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -1515,10 +1512,10 @@ class ImageOSDisk(msrest.serialization.Model): :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemStateTypes :ivar snapshot: The snapshot. :vartype snapshot: ~azure.mgmt.compute.v2017_03_30.models.SubResource @@ -1529,16 +1526,14 @@ class ImageOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", - "Premium_LRS". + values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes """ @@ -1562,24 +1557,23 @@ class ImageOSDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemStateTypes :keyword snapshot: The snapshot. :paramtype snapshot: ~azure.mgmt.compute.v2017_03_30.models.SubResource @@ -1590,15 +1584,14 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", + Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes @@ -1730,8 +1723,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: "ImageOSDisk", - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: "_models.ImageOSDisk", + data_disks: Optional[List["_models.ImageDataDisk"]] = None, **kwargs ): """ @@ -1788,7 +1781,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2017_03_30.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -1810,7 +1803,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -1819,7 +1812,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2017_03_30.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -1860,7 +1853,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -1899,7 +1892,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -1939,7 +1932,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -1978,7 +1971,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -2011,7 +2004,7 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, **kwargs ): """ @@ -2050,7 +2043,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -2080,8 +2073,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2017_03_30.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -2106,7 +2099,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -2122,8 +2115,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2017_03_30.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -2145,8 +2138,7 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", - "Premium_LRS". + values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes """ @@ -2160,14 +2152,14 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", + Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes @@ -2225,7 +2217,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -2292,8 +2284,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -2309,8 +2301,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes :ivar create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -2318,7 +2309,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -2347,22 +2338,22 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -2378,8 +2369,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes :keyword create_option: Required. Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 @@ -2387,7 +2377,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -2413,8 +2403,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes """ @@ -2429,12 +2419,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -2519,9 +2509,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -2819,7 +2809,7 @@ class ResourceSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default: The default capacity. :vartype default: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "Manual", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2017_03_30.models.ResourceSkuCapacityScaleType """ @@ -2899,7 +2889,7 @@ class ResourceSkuRestrictions(msrest.serialization.Model): :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 restriction. Possible values include: "QuotaId", + :ivar reason_code: The reason for restriction. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.compute.v2017_03_30.models.ResourceSkuRestrictionsReasonCode @@ -2953,7 +2943,7 @@ class ResourceSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["ResourceSku"], + value: List["_models.ResourceSku"], next_link: Optional[str] = None, **kwargs ): @@ -3093,13 +3083,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2017_03_30.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2017_03_30.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -3212,8 +3202,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -3242,7 +3231,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -3252,8 +3241,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -3277,8 +3265,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -3314,11 +3301,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -3326,8 +3313,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -3373,7 +3359,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -3454,7 +3440,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -3643,7 +3629,7 @@ class Snapshot(Resource): :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -3690,11 +3676,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ @@ -3704,7 +3690,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. :paramtype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -3752,7 +3738,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -3775,7 +3761,7 @@ class SnapshotUpdate(ResourceUpdate): :vartype tags: dict[str, str] :ivar sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. :vartype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -3798,10 +3784,10 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ @@ -3809,7 +3795,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The disks and snapshots sku name. Can be Standard_LRS or Premium_LRS. :paramtype sku: ~azure.mgmt.compute.v2017_03_30.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -3864,7 +3850,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -3946,9 +3932,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -4033,8 +4019,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2017_03_30.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -4053,8 +4039,8 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, automatic_os_upgrade: Optional[bool] = None, **kwargs ): @@ -4063,8 +4049,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2017_03_30.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -4117,7 +4103,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -4239,8 +4225,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -4388,15 +4374,15 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -4486,8 +4472,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -4665,7 +4651,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -4730,7 +4716,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -4867,8 +4853,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -4905,7 +4891,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -5170,9 +5156,9 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, **kwargs ): """ @@ -5246,12 +5232,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -5315,7 +5301,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -5409,12 +5395,12 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, single_placement_group: Optional[bool] = None, **kwargs @@ -5476,11 +5462,10 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5509,11 +5494,11 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -5526,11 +5511,10 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5669,7 +5653,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -5700,7 +5684,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs ): """ @@ -5785,7 +5769,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -5845,7 +5829,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2017_03_30.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -5885,13 +5869,13 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -5909,7 +5893,7 @@ def __init__( ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2017_03_30.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -5962,7 +5946,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -6002,7 +5986,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -6042,7 +6026,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -6063,7 +6047,7 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. Possible values are: - Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", "Premium_LRS". + Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes """ @@ -6075,13 +6059,13 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. Possible values - are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", "Premium_LRS". + are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2017_03_30.models.StorageAccountTypes """ @@ -6135,9 +6119,9 @@ def __init__( id: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, **kwargs ): """ @@ -6214,8 +6198,8 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -6242,20 +6226,19 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes :ivar create_option: Required. Specifies how the virtual machines in the scale set should be created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk @@ -6284,13 +6267,13 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -6299,20 +6282,19 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes :keyword create_option: Required. Specifies how the virtual machines in the scale set should be created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2017_03_30.models.DiskCreateOptionTypes :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_03_30.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2017_03_30.models.VirtualHardDisk @@ -6408,9 +6390,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -6508,7 +6490,7 @@ def __init__( *, name: str, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, **kwargs ): """ @@ -6609,8 +6591,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetSkuScaleType """ @@ -6672,9 +6653,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -6741,11 +6722,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, single_placement_group: Optional[bool] = None, **kwargs @@ -6800,7 +6781,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2017_03_30.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -6830,13 +6811,13 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -6854,7 +6835,7 @@ def __init__( ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2017_03_30.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -6917,9 +6898,9 @@ def __init__( name: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, **kwargs ): """ @@ -6965,7 +6946,7 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, **kwargs ): """ @@ -6980,7 +6961,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes :ivar image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before using it to attach to the Virtual Machine. If SourceImage is provided, the destination @@ -7003,14 +6984,14 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_03_30.models.CachingTypes :keyword image: The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before using it to attach to the Virtual Machine. If SourceImage is provided, the destination @@ -7053,9 +7034,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -7098,7 +7079,7 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, **kwargs ): """ @@ -7137,9 +7118,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -7190,11 +7171,11 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, **kwargs ): @@ -7339,13 +7320,13 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -7558,11 +7539,11 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -7628,7 +7609,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -7687,11 +7668,11 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, **kwargs ): @@ -7810,7 +7791,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -7889,8 +7870,8 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -7935,7 +7916,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -7950,8 +7931,8 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :vartype protocol: str or ~azure.mgmt.compute.v2017_03_30.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault @@ -7971,14 +7952,14 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2017_03_30.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/__init__.py index e754e54122d1..6b954038534d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/__init__.py @@ -23,6 +23,9 @@ from ._snapshots_operations import SnapshotsOperations from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations +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__ = [ 'AvailabilitySetsOperations', 'VirtualMachineExtensionImagesOperations', @@ -41,3 +44,5 @@ 'SnapshotsOperations', 'VirtualMachineRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_availability_sets_operations.py index 84a9f8b624f1..c2efe087d529 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -77,9 +78,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -91,18 +95,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -113,9 +115,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -127,18 +132,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -149,9 +152,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -161,20 +167,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -184,9 +188,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -197,18 +204,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -219,9 +224,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -233,51 +241,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -291,14 +295,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -310,11 +317,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -341,7 +350,7 @@ def delete( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: + ) -> Optional[_models.OperationStatusResponse]: """Delete an availability set. :param resource_group_name: The name of the resource group. @@ -353,13 +362,16 @@ def delete( :rtype: ~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request( @@ -368,11 +380,13 @@ def delete( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -413,13 +427,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -428,11 +445,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -471,13 +490,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -486,9 +508,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -497,9 +521,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -537,7 +563,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -549,13 +575,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -564,9 +593,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -575,9 +606,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -616,7 +649,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -631,13 +664,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -647,9 +683,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -659,9 +697,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_disks_operations.py index d13e576d3c5e..325f94c155ac 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -260,14 +266,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -279,20 +288,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -305,9 +312,12 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -319,58 +329,57 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -382,11 +391,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -416,9 +427,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -441,37 +452,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -488,17 +509,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -510,11 +534,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -544,9 +570,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -569,37 +595,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -618,7 +654,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -632,13 +668,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -647,11 +686,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -677,14 +718,17 @@ def _delete_initial( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -693,11 +737,13 @@ def _delete_initial( disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -726,7 +772,7 @@ def begin_delete( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a disk. :param resource_group_name: The name of the resource group. @@ -749,34 +795,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -794,7 +850,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -804,13 +860,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -819,9 +878,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -830,9 +891,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -869,7 +932,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -877,13 +940,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -891,9 +957,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -901,9 +969,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -940,17 +1010,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -962,11 +1035,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -994,9 +1069,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -1020,37 +1095,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1068,14 +1153,17 @@ def _revoke_access_initial( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_revoke_access_request_initial( @@ -1084,11 +1172,13 @@ def _revoke_access_initial( disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1117,7 +1207,7 @@ def begin_revoke_access( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Revokes access to a disk. :param resource_group_name: The name of the resource group. @@ -1140,34 +1230,44 @@ def begin_revoke_access( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_images_operations.py index 62dc48021c79..9a4c41bbffaa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,9 +80,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -93,18 +97,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -117,9 +119,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -154,9 +157,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -167,18 +173,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +191,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -199,58 +206,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -262,11 +268,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -296,9 +304,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -319,37 +327,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -367,14 +385,17 @@ def _delete_initial( resource_group_name: str, image_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -383,11 +404,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -416,7 +439,7 @@ def begin_delete( resource_group_name: str, image_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes an Image. :param resource_group_name: The name of the resource group. @@ -437,34 +460,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -484,7 +517,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -498,13 +531,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -514,11 +550,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -544,7 +582,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -554,13 +592,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -569,9 +610,11 @@ def prepare_request(next_link=None): 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: @@ -580,9 +623,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -619,7 +664,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -628,13 +673,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -642,9 +690,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -652,9 +702,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_resource_skus_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_resource_skus_operations.py index b66e208aac2c..1fb8ddaf3b4b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_resource_skus_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_resource_skus_operations.py @@ -16,6 +16,7 @@ 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 @@ -30,9 +31,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/skus") path_format_arguments = { @@ -42,48 +46,44 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ResourceSkusOperations(object): - """ResourceSkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`resource_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.ResourceSkusResult"]: + ) -> Iterable[_models.ResourceSkusResult]: """Gets the list of Microsoft.Compute SKUs available for your Subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -91,13 +91,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.ResourceSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -105,9 +108,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -115,9 +120,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_snapshots_operations.py index 9619dbeca29d..8e7b1ceba37c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -260,14 +266,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -279,20 +288,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -305,9 +312,12 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -319,58 +329,57 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -382,11 +391,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -416,9 +427,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -441,37 +452,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -488,17 +509,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -510,11 +534,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -544,9 +570,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -569,37 +595,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -618,7 +654,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -632,13 +668,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -647,11 +686,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -677,14 +718,17 @@ def _delete_initial( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -693,11 +737,13 @@ def _delete_initial( snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -726,7 +772,7 @@ def begin_delete( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a snapshot. :param resource_group_name: The name of the resource group. @@ -749,34 +795,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -794,7 +850,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -804,13 +860,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -819,9 +878,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -830,9 +891,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -869,7 +932,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -877,13 +940,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -891,9 +957,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -901,9 +969,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -940,17 +1010,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -962,11 +1035,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -994,9 +1069,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -1020,37 +1095,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1068,14 +1153,17 @@ def _revoke_access_initial( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_revoke_access_request_initial( @@ -1084,11 +1172,13 @@ def _revoke_access_initial( snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1117,7 +1207,7 @@ def begin_revoke_access( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Revokes access to a snapshot. :param resource_group_name: The name of the resource group. @@ -1140,34 +1230,44 @@ def begin_revoke_access( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_usage_operations.py index c3519fd67b28..1849ff7575dd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_extension_images_operations.py index 2763749c693f..dfce9a39add1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_extensions_operations.py index 5938fd7896ff..922681ecba55 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,9 +129,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,18 +147,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -167,9 +170,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -182,61 +188,60 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -249,11 +254,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -284,9 +291,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -313,17 +320,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -331,20 +341,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -362,17 +379,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -385,11 +405,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -416,9 +438,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -445,17 +467,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -463,20 +488,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -495,14 +527,17 @@ def _delete_initial( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -512,11 +547,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -546,7 +583,7 @@ def begin_delete( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -569,35 +606,45 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -618,7 +665,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -634,13 +681,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -651,11 +701,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_images_operations.py index f976b5645a60..178812783802 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_run_commands_operations.py index e258b5a50b29..b27c720e12f8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_run_commands_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -44,18 +48,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -66,9 +68,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -80,49 +85,45 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -134,13 +135,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -149,9 +153,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -160,9 +166,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -201,7 +209,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -213,13 +221,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -228,11 +239,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_set_extensions_operations.py index c5c143fffbc5..abd32c4e42d7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,9 +83,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,18 +101,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -122,9 +124,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,20 +142,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -161,9 +164,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -175,59 +181,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -240,11 +245,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -275,9 +282,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -305,17 +312,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -323,20 +333,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -355,14 +372,17 @@ def _delete_initial( vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -372,11 +392,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -406,7 +428,7 @@ def begin_delete( vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -429,35 +451,45 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -478,7 +510,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -494,13 +526,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -511,11 +546,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -542,7 +579,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -556,13 +593,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -572,9 +612,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -584,9 +626,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 47a87d6f8529..aaa2a12379f9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,9 +34,12 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +51,16 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -69,9 +71,12 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -83,18 +88,16 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -105,9 +108,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -119,56 +125,55 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_cancel_request_initial( @@ -177,11 +182,13 @@ def _cancel_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -210,7 +217,7 @@ def begin_cancel( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Cancels the current virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -231,34 +238,44 @@ def begin_cancel( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -276,14 +293,17 @@ def _start_os_upgrade_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_os_upgrade_request_initial( @@ -292,11 +312,13 @@ def _start_os_upgrade_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -325,7 +347,7 @@ def begin_start_os_upgrade( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Starts a rolling upgrade to move all virtual machine scale set instances to the latest available Platform Image OS version. Instances which are already running the latest available OS version are not affected. @@ -348,34 +370,44 @@ def begin_start_os_upgrade( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -394,7 +426,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -406,13 +438,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2017_03_30.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -421,11 +456,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_set_vms_operations.py index a776748f2eae..f6d733ae4c4f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,6 +17,7 @@ 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 @@ -35,9 +36,12 @@ def build_reimage_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -50,18 +54,16 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -73,9 +75,12 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -88,18 +93,16 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -111,9 +114,12 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -126,18 +132,16 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -149,9 +153,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -164,18 +171,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +192,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -202,18 +210,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +231,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -240,18 +249,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -266,9 +273,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -280,24 +290,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -309,9 +317,12 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -324,18 +335,16 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -347,9 +356,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -362,18 +374,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -385,9 +395,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -400,42 +413,38 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( self, @@ -443,14 +452,17 @@ def _reimage_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_request_initial( @@ -460,11 +472,13 @@ def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -494,7 +508,7 @@ def begin_reimage( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -517,35 +531,45 @@ def begin_reimage( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -564,14 +588,17 @@ def _reimage_all_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_all_request_initial( @@ -581,11 +608,13 @@ def _reimage_all_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -615,7 +644,7 @@ def begin_reimage_all( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. This operation is only supported for managed disks. @@ -639,35 +668,45 @@ def begin_reimage_all( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -686,14 +725,17 @@ def _deallocate_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -703,11 +745,13 @@ def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -737,7 +781,7 @@ def begin_deallocate( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and releases the compute resources it uses. You are not billed for the compute resources of this virtual machine once it is deallocated. @@ -762,35 +806,45 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -809,14 +863,17 @@ def _delete_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -826,11 +883,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -860,7 +919,7 @@ def begin_delete( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -883,35 +942,45 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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( @@ -931,7 +1000,7 @@ def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -945,13 +1014,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -961,11 +1033,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -993,7 +1067,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1007,13 +1081,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1023,11 +1100,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1057,7 +1136,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1081,13 +1160,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1100,9 +1182,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1115,9 +1199,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1156,14 +1242,17 @@ def _power_off_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -1173,11 +1262,13 @@ def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1207,7 +1298,7 @@ def begin_power_off( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -1232,35 +1323,45 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1279,14 +1380,17 @@ def _restart_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -1296,11 +1400,13 @@ def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1330,7 +1436,7 @@ def begin_restart( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Restarts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1353,35 +1459,45 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1400,14 +1516,17 @@ def _start_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1417,11 +1536,13 @@ def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1451,7 +1572,7 @@ def begin_start( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Starts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1474,35 +1595,45 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_sets_operations.py index 526ea8284e2f..c2c5b4f7bc6b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,14 +198,17 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -213,20 +220,18 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -238,14 +243,17 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -257,20 +265,18 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -283,9 +289,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -297,18 +306,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -318,9 +325,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -331,18 +341,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -351,9 +359,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -363,18 +374,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -385,9 +394,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -399,18 +411,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -420,14 +430,17 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -439,20 +452,18 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -464,14 +475,17 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -483,20 +497,18 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -508,14 +520,17 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -527,20 +542,18 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -552,14 +565,17 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -571,20 +587,18 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -596,14 +610,17 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -615,20 +632,18 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -640,14 +655,17 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -659,62 +677,61 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -726,11 +743,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -760,9 +779,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -785,37 +804,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -832,17 +861,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -854,11 +886,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -884,9 +918,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -909,37 +943,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -957,14 +1001,17 @@ def _delete_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -973,11 +1020,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1006,7 +1055,7 @@ def begin_delete( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a VM scale set. :param resource_group_name: The name of the resource group. @@ -1027,34 +1076,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -1073,7 +1132,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1085,13 +1144,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1100,11 +1162,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1129,17 +1193,20 @@ def _deallocate_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1154,11 +1221,13 @@ def _deallocate_initial( content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1186,9 +1255,9 @@ def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. @@ -1215,37 +1284,47 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1262,17 +1341,20 @@ def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # 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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1284,11 +1366,13 @@ def _delete_instances_initial( content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1316,9 +1400,9 @@ def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1342,37 +1426,47 @@ def begin_delete_instances( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1391,7 +1485,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1403,13 +1497,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1418,11 +1515,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1448,7 +1547,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1460,13 +1559,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1475,9 +1577,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1486,9 +1590,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1525,7 +1631,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1537,13 +1643,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1551,9 +1660,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1561,9 +1672,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1602,7 +1715,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1617,13 +1730,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1633,9 +1749,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1645,9 +1763,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1684,17 +1804,20 @@ def _power_off_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1709,11 +1832,13 @@ def _power_off_initial( content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1741,9 +1866,9 @@ def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -1770,37 +1895,47 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1817,17 +1952,20 @@ def _restart_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1842,11 +1980,13 @@ def _restart_initial( content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1874,9 +2014,9 @@ def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1901,37 +2041,47 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1948,17 +2098,20 @@ def _start_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1973,11 +2126,13 @@ def _start_initial( content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2005,9 +2160,9 @@ def begin_start( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2032,37 +2187,47 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2079,17 +2244,20 @@ def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2101,11 +2269,13 @@ def _update_instances_initial( content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2133,9 +2303,9 @@ def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. @@ -2159,37 +2329,47 @@ def begin_update_instances( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2206,17 +2386,20 @@ def _reimage_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2231,11 +2414,13 @@ def _reimage_initial( content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2263,9 +2448,9 @@ def begin_reimage( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2290,37 +2475,47 @@ def begin_reimage( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2337,17 +2532,20 @@ def _reimage_all_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # 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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2362,11 +2560,13 @@ def _reimage_all_initial( content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2394,9 +2594,9 @@ def begin_reimage_all( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This operation is only supported for managed disks. @@ -2422,37 +2622,47 @@ def begin_reimage_all( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_sizes_operations.py index 679b1613a89f..083b92843c0f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes for a subscription in a location. :param location: The location upon which virtual-machine-sizes is queried. @@ -98,13 +98,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -113,9 +116,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -124,9 +129,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machines_operations.py index 568588e95290..ce96ed6ecf3f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_03_30/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +37,12 @@ def build_get_extensions_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_get_extensions_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -74,9 +75,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -87,18 +91,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -108,14 +110,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -127,20 +132,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,14 +155,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,20 +177,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -197,9 +201,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -211,18 +218,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -235,9 +240,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -249,20 +257,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -273,9 +279,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -287,18 +296,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -309,9 +316,12 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -323,18 +333,16 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -345,9 +353,12 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -359,18 +370,16 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -381,9 +390,12 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -395,18 +407,16 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -416,9 +426,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -429,18 +442,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -449,9 +460,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -461,18 +475,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -483,9 +495,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -497,18 +512,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -519,9 +532,12 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -533,18 +549,16 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -555,9 +569,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -569,18 +586,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -591,9 +606,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -605,18 +623,16 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -627,9 +643,12 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -641,18 +660,16 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -663,9 +680,12 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = case_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-03-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -677,18 +697,16 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -698,14 +716,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -717,46 +738,42 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2017_03_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2017_03_30.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_extensions( @@ -765,7 +782,7 @@ def get_extensions( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -779,13 +796,16 @@ def get_extensions( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_get_extensions_request( @@ -795,11 +815,13 @@ def get_extensions( api_version=api_version, expand=expand, template_url=self.get_extensions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -825,7 +847,7 @@ def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -837,13 +859,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -852,9 +877,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -863,9 +890,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -902,17 +931,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -924,11 +956,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -956,9 +990,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -982,37 +1016,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1029,17 +1073,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -1051,11 +1098,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1085,9 +1134,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1109,37 +1158,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-03-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1157,14 +1216,17 @@ def _delete_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -1173,11 +1235,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1206,7 +1270,7 @@ def begin_delete( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to delete a virtual machine. :param resource_group_name: The name of the resource group. @@ -1227,34 +1291,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -1274,28 +1348,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1305,11 +1382,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1336,7 +1415,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1348,13 +1427,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2017_03_30.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1363,11 +1445,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1393,14 +1477,17 @@ def _convert_to_managed_disks_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_convert_to_managed_disks_request_initial( @@ -1409,11 +1496,13 @@ def _convert_to_managed_disks_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1442,7 +1531,7 @@ def begin_convert_to_managed_disks( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation. @@ -1464,34 +1553,44 @@ def begin_convert_to_managed_disks( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1509,14 +1608,17 @@ def _deallocate_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -1525,11 +1627,13 @@ def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1558,7 +1662,7 @@ def begin_deallocate( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses. @@ -1580,34 +1684,44 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1626,7 +1740,7 @@ def generalize( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.OperationStatusResponse": + ) -> _models.OperationStatusResponse: """Sets the state of the virtual machine to generalized. :param resource_group_name: The name of the resource group. @@ -1638,13 +1752,16 @@ def generalize( :rtype: ~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] request = build_generalize_request( @@ -1653,11 +1770,13 @@ def generalize( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1683,7 +1802,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1696,13 +1815,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1711,9 +1833,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1722,9 +1846,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1761,7 +1887,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1772,13 +1898,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1786,9 +1915,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1796,9 +1927,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1837,7 +1970,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1852,13 +1985,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_03_30.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1868,9 +2004,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1880,9 +2018,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1920,14 +2060,17 @@ def _power_off_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -1936,11 +2079,13 @@ def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1969,7 +2114,7 @@ def begin_power_off( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine. @@ -1991,34 +2136,44 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2036,14 +2191,17 @@ def _restart_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -2052,11 +2210,13 @@ def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2085,7 +2245,7 @@ def begin_restart( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to restart a virtual machine. :param resource_group_name: The name of the resource group. @@ -2106,34 +2266,44 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2151,14 +2321,17 @@ def _start_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -2167,11 +2340,13 @@ def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2200,7 +2375,7 @@ def begin_start( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to start a virtual machine. :param resource_group_name: The name of the resource group. @@ -2221,34 +2396,44 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2266,14 +2451,17 @@ def _redeploy_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_redeploy_request_initial( @@ -2282,11 +2470,13 @@ def _redeploy_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2315,7 +2505,7 @@ def begin_redeploy( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine, moves it to a new node, and powers it back on. :param resource_group_name: The name of the resource group. @@ -2336,34 +2526,44 @@ def begin_redeploy( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2381,14 +2581,17 @@ def _perform_maintenance_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_perform_maintenance_request_initial( @@ -2397,11 +2600,13 @@ def _perform_maintenance_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2430,7 +2635,7 @@ def begin_perform_maintenance( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to perform maintenance on a virtual machine. :param resource_group_name: The name of the resource group. @@ -2451,34 +2656,44 @@ def begin_perform_maintenance( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2495,18 +2710,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2518,11 +2736,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2550,11 +2770,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2563,7 +2783,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2017_03_30.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2579,36 +2799,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_03_30.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-03-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-03-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_compute_management_client.py index 8eb3d72f6818..133673979626 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_compute_management_client.py @@ -53,7 +53,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_skus = ResourceSkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/_compute_management_client.py index 1ea7644a0fb2..38b17e016f67 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/_compute_management_client.py @@ -53,7 +53,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_skus = ResourceSkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/__init__.py index 46d684b6a0cc..9aa451b77759 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/__init__.py @@ -8,6 +8,11 @@ from ._resource_skus_operations import ResourceSkusOperations +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__ = [ 'ResourceSkusOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/_resource_skus_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/_resource_skus_operations.py index 84ad3e90f706..322cf476fd7d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/_resource_skus_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/aio/operations/_resource_skus_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ResourceSkusOperations: - """ResourceSkusOperations async operations. - - You 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.compute.v2017_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.compute.v2017_09_01.aio.ComputeManagementClient`'s + :attr:`resource_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.ResourceSkusResult"]: + ) -> AsyncIterable[_models.ResourceSkusResult]: """Gets the list of Microsoft.Compute SKUs available for your Subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -57,13 +56,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_09_01.models.ResourceSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -71,9 +73,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -81,9 +85,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/__init__.py index 8bbfb0f84192..ba2da4bb237c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/__init__.py @@ -21,7 +21,9 @@ ResourceSkuRestrictionsReasonCode, ResourceSkuRestrictionsType, ) - +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__ = [ 'ResourceSku', 'ResourceSkuCapabilities', @@ -35,3 +37,5 @@ 'ResourceSkuRestrictionsReasonCode', 'ResourceSkuRestrictionsType', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_compute_management_client_enums.py index d85caa49fe4f..1f65e79f3a25 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ @@ -19,14 +18,14 @@ class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, MANUAL = "Manual" NONE = "None" -class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for restriction. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ResourceSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of restrictions. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_models_py3.py index 2026b224642f..e73d84634cea 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_models_py3.py @@ -6,10 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional +from typing import List, Optional, TYPE_CHECKING import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ResourceSku(msrest.serialization.Model): """Describes an available Compute SKU. @@ -145,7 +149,7 @@ class ResourceSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default: The default capacity. :vartype default: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "Manual", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2017_09_01.models.ResourceSkuCapacityScaleType """ @@ -283,14 +287,14 @@ class ResourceSkuRestrictions(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of restrictions. Possible values include: "Location", "Zone". + :ivar type: The type of restrictions. Known values are: "Location", "Zone". :vartype type: str or ~azure.mgmt.compute.v2017_09_01.models.ResourceSkuRestrictionsType :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 restriction_info: The information about the restriction where the SKU cannot be used. :vartype restriction_info: ~azure.mgmt.compute.v2017_09_01.models.ResourceSkuRestrictionInfo - :ivar reason_code: The reason for restriction. Possible values include: "QuotaId", + :ivar reason_code: The reason for restriction. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.compute.v2017_09_01.models.ResourceSkuRestrictionsReasonCode @@ -347,7 +351,7 @@ class ResourceSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["ResourceSku"], + value: List["_models.ResourceSku"], next_link: Optional[str] = None, **kwargs ): diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/__init__.py index 46d684b6a0cc..9aa451b77759 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/__init__.py @@ -8,6 +8,11 @@ from ._resource_skus_operations import ResourceSkusOperations +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__ = [ 'ResourceSkusOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/_resource_skus_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/_resource_skus_operations.py index 86084c98e256..f7b09c9ab719 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/_resource_skus_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_09_01/operations/_resource_skus_operations.py @@ -16,6 +16,7 @@ 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 @@ -30,9 +31,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-09-01") # type: str + _headers = case_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-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/skus") path_format_arguments = { @@ -42,48 +46,44 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ResourceSkusOperations(object): - """ResourceSkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_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.compute.v2017_09_01.ComputeManagementClient`'s + :attr:`resource_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.ResourceSkusResult"]: + ) -> Iterable[_models.ResourceSkusResult]: """Gets the list of Microsoft.Compute SKUs available for your Subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -91,13 +91,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_09_01.models.ResourceSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-09-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -105,9 +108,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -115,9 +120,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_compute_management_client.py index 4c90377d59f7..2677d23d4bb9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_compute_management_client.py @@ -95,21 +95,51 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/_compute_management_client.py index 0e2d7fb9e709..bbaabec4df03 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/_compute_management_client.py @@ -96,21 +96,51 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/__init__.py index 3ad29360b8dc..c49c1eccc6ce 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/__init__.py @@ -22,6 +22,9 @@ from ._log_analytics_operations import LogAnalyticsOperations from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations +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', 'AvailabilitySetsOperations', @@ -39,3 +42,5 @@ 'LogAnalyticsOperations', 'VirtualMachineRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_availability_sets_operations.py index 4eb935b332cd..5c9da1c19ab4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -181,7 +190,7 @@ async def delete( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: + ) -> Optional[_models.OperationStatusResponse]: """Delete an availability set. :param resource_group_name: The name of the resource group. @@ -193,13 +202,16 @@ async def delete( :rtype: ~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,7 +255,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -253,13 +267,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -268,11 +285,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -298,7 +317,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -311,13 +330,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -326,9 +348,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -337,9 +361,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -377,7 +403,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -389,13 +415,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -404,9 +433,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -415,9 +446,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -456,7 +489,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -471,13 +504,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -487,9 +523,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -499,9 +537,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_images_operations.py index e7587f967d88..d40f220f62f4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -304,14 +333,17 @@ async def _delete_initial( resource_group_name: str, image_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -353,7 +387,7 @@ async def begin_delete( resource_group_name: str, image_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes an Image. :param resource_group_name: The name of the resource group. @@ -374,34 +408,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -421,7 +465,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -435,13 +479,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -451,11 +498,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -481,7 +530,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -492,13 +541,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -507,9 +559,11 @@ def prepare_request(next_link=None): 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: @@ -518,9 +572,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -557,7 +613,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -567,13 +623,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -581,9 +640,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -591,9 +652,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_log_analytics_operations.py index b3808137c9b2..ec9279255c17 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_operations.py index 4014ccda48d2..02bba0bcc311 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_usage_operations.py index b665d9fe2f87..8e5f7bb777da 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_extension_images_operations.py index 12e383939eda..6029e8b18a7d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_extensions_operations.py index d5365664aa83..d7aef7e91c5b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -319,14 +348,17 @@ async def _delete_initial( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -370,7 +404,7 @@ async def begin_delete( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -393,35 +427,45 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -442,7 +486,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -458,13 +502,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -475,11 +522,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_images_operations.py index 2d230b4c2550..16b53909bd0a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_run_commands_operations.py index ca77d56c73dd..87dfd07ca105 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -15,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 @@ -24,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,7 +135,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -141,13 +147,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -156,11 +165,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index 0d45a4ad37bf..bae55cabb97d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -190,14 +204,17 @@ async def _delete_initial( vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -207,11 +224,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,7 +260,7 @@ async def begin_delete( vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -264,35 +283,45 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -313,7 +342,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -329,13 +358,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -346,11 +378,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -377,7 +411,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -391,13 +425,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -407,9 +444,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -419,9 +458,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index a6bda7165f4c..7cbff51921cb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,40 +25,41 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -99,7 +103,7 @@ async def begin_cancel( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Cancels the current virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -120,34 +124,44 @@ async def begin_cancel( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -165,14 +179,17 @@ async def _start_os_upgrade_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_os_upgrade_request_initial( @@ -181,11 +198,13 @@ async def _start_os_upgrade_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -214,7 +233,7 @@ async def begin_start_os_upgrade( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Starts a rolling upgrade to move all virtual machine scale set instances to the latest available Platform Image OS version. Instances which are already running the latest available OS version are not affected. @@ -237,34 +256,44 @@ async def begin_start_os_upgrade( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -283,7 +312,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -295,13 +324,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -310,11 +342,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index 153345eb0e5b..c69d53d9cfe1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( self, @@ -53,14 +52,17 @@ async def _reimage_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_request_initial( @@ -70,11 +72,13 @@ async def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -104,7 +108,7 @@ async def begin_reimage( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -127,35 +131,45 @@ async def begin_reimage( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -174,14 +188,17 @@ async def _reimage_all_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_all_request_initial( @@ -191,11 +208,13 @@ async def _reimage_all_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -225,7 +244,7 @@ async def begin_reimage_all( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. This operation is only supported for managed disks. @@ -249,35 +268,45 @@ async def begin_reimage_all( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -296,14 +325,17 @@ async def _deallocate_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -313,11 +345,13 @@ async def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,7 +381,7 @@ async def begin_deallocate( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and releases the compute resources it uses. You are not billed for the compute resources of this virtual machine once it is deallocated. @@ -372,35 +406,45 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -418,17 +462,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -441,11 +488,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -476,9 +525,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -504,17 +553,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -522,20 +574,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -554,14 +613,17 @@ async def _delete_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -571,11 +633,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -605,7 +669,7 @@ async def begin_delete( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -628,35 +692,45 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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( @@ -676,7 +750,7 @@ async def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -690,13 +764,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -706,11 +783,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -738,7 +817,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -752,13 +831,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -768,11 +850,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -802,7 +886,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -826,13 +910,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -845,9 +932,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -860,9 +949,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -901,14 +992,17 @@ async def _power_off_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -918,11 +1012,13 @@ async def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -952,7 +1048,7 @@ async def begin_power_off( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -977,35 +1073,45 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1024,14 +1130,17 @@ async def _restart_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -1041,11 +1150,13 @@ async def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1075,7 +1186,7 @@ async def begin_restart( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Restarts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1098,35 +1209,45 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1145,14 +1266,17 @@ async def _start_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1162,11 +1286,13 @@ async def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1196,7 +1322,7 @@ async def begin_start( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Starts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1219,35 +1345,45 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1266,14 +1402,17 @@ async def _redeploy_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_redeploy_request_initial( @@ -1283,11 +1422,13 @@ async def _redeploy_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1317,7 +1458,7 @@ async def begin_redeploy( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and powers it back on. @@ -1341,35 +1482,45 @@ async def begin_redeploy( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1388,14 +1539,17 @@ async def _perform_maintenance_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_perform_maintenance_request_initial( @@ -1405,11 +1559,13 @@ async def _perform_maintenance_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1439,7 +1595,7 @@ async def begin_perform_maintenance( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Performs maintenance on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1462,35 +1618,45 @@ async def begin_perform_maintenance( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_sets_operations.py index 38d05767a4db..54103b45fa95 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -231,9 +250,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -304,14 +333,17 @@ async def _delete_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -353,7 +387,7 @@ async def begin_delete( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes a VM scale set. :param resource_group_name: The name of the resource group. @@ -374,34 +408,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -420,7 +464,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -432,13 +476,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -447,11 +494,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -476,17 +525,20 @@ async def _deallocate_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -501,11 +553,13 @@ async def _deallocate_initial( content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -533,9 +587,9 @@ async def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. @@ -562,37 +616,47 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -609,17 +673,20 @@ async def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -631,11 +698,13 @@ async def _delete_instances_initial( content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -663,9 +732,9 @@ async def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -689,37 +758,47 @@ async def begin_delete_instances( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -738,7 +817,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -750,13 +829,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -765,11 +847,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -795,7 +879,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -807,13 +891,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -822,9 +909,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -833,9 +922,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -872,7 +963,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -884,13 +975,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -898,9 +992,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -908,9 +1004,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +1047,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -964,13 +1062,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -980,9 +1081,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -992,9 +1095,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1033,7 +1138,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1047,13 +1152,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1063,9 +1171,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1075,9 +1185,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1114,17 +1226,20 @@ async def _power_off_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1139,11 +1254,13 @@ async def _power_off_initial( content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1171,9 +1288,9 @@ async def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -1200,37 +1317,47 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1247,17 +1374,20 @@ async def _restart_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1272,11 +1402,13 @@ async def _restart_initial( content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1304,9 +1436,9 @@ async def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1331,37 +1463,47 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1378,17 +1520,20 @@ async def _start_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1403,11 +1548,13 @@ async def _start_initial( content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1435,9 +1582,9 @@ async def begin_start( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1462,37 +1609,47 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1509,17 +1666,20 @@ async def _redeploy_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1534,11 +1694,13 @@ async def _redeploy_initial( content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1566,9 +1728,9 @@ async def begin_redeploy( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, and powers them back on. @@ -1594,37 +1756,47 @@ async def begin_redeploy( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1641,17 +1813,20 @@ async def _perform_maintenance_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1666,11 +1841,13 @@ async def _perform_maintenance_initial( content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1698,9 +1875,9 @@ async def begin_perform_maintenance( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances which are not eligible for perform maintenance will be failed. Please refer to best practices for more details: @@ -1728,37 +1905,47 @@ async def begin_perform_maintenance( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1775,17 +1962,20 @@ async def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1797,11 +1987,13 @@ async def _update_instances_initial( content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1829,9 +2021,9 @@ async def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. @@ -1855,37 +2047,47 @@ async def begin_update_instances( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1902,17 +2104,20 @@ async def _reimage_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1927,11 +2132,13 @@ async def _reimage_initial( content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1959,9 +2166,9 @@ async def begin_reimage( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1986,37 +2193,47 @@ async def begin_reimage( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -2033,17 +2250,20 @@ async def _reimage_all_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2058,11 +2278,13 @@ async def _reimage_all_initial( content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2090,9 +2312,9 @@ async def begin_reimage_all( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This operation is only supported for managed disks. @@ -2118,37 +2340,47 @@ async def begin_reimage_all( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -2168,7 +2400,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2184,13 +2416,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2017_12_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2200,11 +2435,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_sizes_operations.py index 4675faa4d70c..46837a540918 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes for a subscription in a location. :param location: The location upon which virtual-machine-sizes is queried. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machines_operations.py index cf9e3e605ac3..3ec3a228a56b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2017_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.compute.v2017_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_extensions( @@ -54,7 +53,7 @@ async def get_extensions( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -68,13 +67,16 @@ async def get_extensions( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_get_extensions_request( @@ -84,11 +86,13 @@ async def get_extensions( api_version=api_version, expand=expand, template_url=self.get_extensions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -114,7 +118,7 @@ def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -126,13 +130,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -141,9 +148,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -152,9 +161,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -191,17 +202,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -213,11 +227,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -245,9 +261,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -271,37 +287,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -318,17 +344,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -340,11 +369,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -374,9 +405,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -399,37 +430,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -446,17 +487,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -468,11 +512,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,9 +548,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -527,37 +573,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -575,14 +631,17 @@ async def _delete_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -591,11 +650,13 @@ async def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -624,7 +685,7 @@ async def begin_delete( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to delete a virtual machine. :param resource_group_name: The name of the resource group. @@ -645,34 +706,44 @@ async def begin_delete( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -692,28 +763,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -723,11 +797,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -754,7 +830,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -766,13 +842,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -781,11 +860,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -811,14 +892,17 @@ async def _convert_to_managed_disks_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_convert_to_managed_disks_request_initial( @@ -827,11 +911,13 @@ async def _convert_to_managed_disks_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -860,7 +946,7 @@ async def begin_convert_to_managed_disks( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation. @@ -882,34 +968,44 @@ async def begin_convert_to_managed_disks( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -927,14 +1023,17 @@ async def _deallocate_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -943,11 +1042,13 @@ async def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -976,7 +1077,7 @@ async def begin_deallocate( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses. @@ -998,34 +1099,44 @@ async def begin_deallocate( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1044,7 +1155,7 @@ async def generalize( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.OperationStatusResponse": + ) -> _models.OperationStatusResponse: """Sets the state of the virtual machine to generalized. :param resource_group_name: The name of the resource group. @@ -1056,13 +1167,16 @@ async def generalize( :rtype: ~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] request = build_generalize_request( @@ -1071,11 +1185,13 @@ async def generalize( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1101,7 +1217,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1114,13 +1230,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1129,9 +1248,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1140,9 +1261,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1179,7 +1302,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1190,13 +1313,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1204,9 +1330,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1214,9 +1342,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1255,7 +1385,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1270,13 +1400,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1286,9 +1419,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1298,9 +1433,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1338,14 +1475,17 @@ async def _power_off_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -1354,11 +1494,13 @@ async def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1387,7 +1529,7 @@ async def begin_power_off( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine. @@ -1409,34 +1551,44 @@ async def begin_power_off( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1454,14 +1606,17 @@ async def _restart_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -1470,11 +1625,13 @@ async def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1503,7 +1660,7 @@ async def begin_restart( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to restart a virtual machine. :param resource_group_name: The name of the resource group. @@ -1524,34 +1681,44 @@ async def begin_restart( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1569,14 +1736,17 @@ async def _start_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1585,11 +1755,13 @@ async def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1618,7 +1790,7 @@ async def begin_start( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to start a virtual machine. :param resource_group_name: The name of the resource group. @@ -1639,34 +1811,44 @@ async def begin_start( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1684,14 +1866,17 @@ async def _redeploy_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_redeploy_request_initial( @@ -1700,11 +1885,13 @@ async def _redeploy_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1733,7 +1920,7 @@ async def begin_redeploy( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine, moves it to a new node, and powers it back on. :param resource_group_name: The name of the resource group. @@ -1754,34 +1941,44 @@ async def begin_redeploy( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1799,14 +1996,17 @@ async def _perform_maintenance_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_perform_maintenance_request_initial( @@ -1815,11 +2015,13 @@ async def _perform_maintenance_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1848,7 +2050,7 @@ async def begin_perform_maintenance( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.OperationStatusResponse"]: + ) -> AsyncLROPoller[_models.OperationStatusResponse]: """The operation to perform maintenance on a virtual machine. :param resource_group_name: The name of the resource group. @@ -1869,34 +2071,44 @@ async def begin_perform_maintenance( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1913,18 +2125,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1936,11 +2151,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1968,11 +2185,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -1981,7 +2198,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2017_12_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1998,36 +2215,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2017_12_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/__init__.py index 715992e54f6c..0fcb186c7c0b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/__init__.py @@ -171,7 +171,9 @@ VirtualMachineScaleSetSkuScaleType, VirtualMachineSizeTypes, ) - +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__ = [ 'AdditionalUnattendContent', 'ApiEntityReference', @@ -335,3 +337,5 @@ 'VirtualMachineScaleSetSkuScaleType', 'VirtualMachineSizeTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_compute_management_client_enums.py index 344b1055104f..7e5811102428 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -22,7 +21,7 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -35,7 +34,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -44,7 +43,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -53,7 +52,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -62,21 +61,21 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ GENERALIZED = "Generalized" SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -84,7 +83,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -95,14 +94,14 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -111,7 +110,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -119,7 +118,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -127,7 +126,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. Possible values are: Standard_LRS or Premium_LRS. """ @@ -135,7 +134,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_LRS = "Standard_LRS" PREMIUM_LRS = "Premium_LRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -147,7 +146,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -155,7 +154,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -164,7 +163,7 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for virtual machines in a low priority scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview """ @@ -172,7 +171,7 @@ class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for the virtual machines in the scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview """ @@ -180,14 +179,14 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E REGULAR = "Regular" LOW = "Low" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. For more information about virtual machine sizes, see `Sizes for virtual machines `_. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_models_py3.py index 7d7591ee39b0..af9c6fbf3f02 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AdditionalUnattendContent(msrest.serialization.Model): @@ -25,7 +27,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2017_12_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -46,7 +48,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -59,7 +61,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2017_12_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -127,8 +129,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -330,10 +332,10 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -383,7 +385,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -460,10 +462,10 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -677,8 +679,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -689,7 +690,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -720,14 +721,14 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ @@ -746,8 +747,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -758,7 +758,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -824,7 +824,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -859,8 +859,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -902,8 +902,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -935,8 +935,8 @@ class HardwareProfile(msrest.serialization.Model): :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -981,7 +981,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -995,8 +995,8 @@ def __init__( :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -1086,8 +1086,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, **kwargs ): """ @@ -1124,16 +1124,14 @@ class ImageDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", - "Premium_LRS". + values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes """ @@ -1156,12 +1154,12 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ @@ -1178,15 +1176,14 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", + Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes @@ -1225,7 +1222,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -1248,10 +1245,10 @@ class ImageOSDisk(msrest.serialization.Model): :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemStateTypes :ivar snapshot: The snapshot. :vartype snapshot: ~azure.mgmt.compute.v2017_12_01.models.SubResource @@ -1262,16 +1259,14 @@ class ImageOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", - "Premium_LRS". + values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes """ @@ -1295,24 +1290,23 @@ class ImageOSDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemStateTypes :keyword snapshot: The snapshot. :paramtype snapshot: ~azure.mgmt.compute.v2017_12_01.models.SubResource @@ -1323,15 +1317,14 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", + Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes @@ -1461,8 +1454,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -1517,8 +1510,8 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, **kwargs ): """ @@ -1572,7 +1565,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2017_12_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -1594,7 +1587,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -1603,7 +1596,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2017_12_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -1645,7 +1638,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -1684,7 +1677,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -1717,7 +1710,7 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, **kwargs ): """ @@ -1756,7 +1749,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -1977,8 +1970,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2017_12_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -2003,7 +1996,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -2019,8 +2012,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2017_12_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -2042,8 +2035,7 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", - "Premium_LRS". + values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes """ @@ -2057,14 +2049,14 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", + Possible values are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes @@ -2122,7 +2114,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -2142,8 +2134,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -2159,8 +2151,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -2171,7 +2162,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -2201,23 +2192,23 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -2233,8 +2224,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -2245,7 +2235,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -2272,8 +2262,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes """ @@ -2288,12 +2278,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -2378,9 +2368,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -2602,7 +2592,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_resource_name: Group query result by Resource Name. :vartype group_by_resource_name: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2017_12_01.models.IntervalInMins """ @@ -2629,7 +2619,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -2650,7 +2640,7 @@ def __init__( :keyword group_by_resource_name: Group query result by Resource Name. :paramtype group_by_resource_name: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2017_12_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, **kwargs) @@ -2819,13 +2809,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -2938,8 +2928,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -2968,7 +2957,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -2978,8 +2967,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -3003,8 +2991,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -3040,11 +3027,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -3052,8 +3039,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -3099,7 +3085,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -3180,7 +3166,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -3356,7 +3342,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -3438,9 +3424,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -3606,7 +3592,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2017_12_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2017_12_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -3653,7 +3639,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2017_12_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -3693,8 +3679,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2017_12_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -3717,10 +3703,10 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, automatic_os_upgrade: Optional[bool] = None, - auto_os_upgrade_policy: Optional["AutoOSUpgradePolicy"] = None, + auto_os_upgrade_policy: Optional["_models.AutoOSUpgradePolicy"] = None, **kwargs ): """ @@ -3728,8 +3714,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2017_12_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -3786,7 +3772,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -3908,8 +3894,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -4057,15 +4043,15 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -4155,8 +4141,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -4334,7 +4320,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -4399,7 +4385,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -4536,8 +4522,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -4574,7 +4560,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -4706,8 +4692,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2017_12_01.models.ResourceIdentityType :ivar identity_ids: The list of user identities associated with the Virtual Machine. The user identity references will be ARM resource ids in the form: @@ -4730,15 +4716,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, identity_ids: Optional[List[str]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2017_12_01.models.ResourceIdentityType :keyword identity_ids: The list of user identities associated with the Virtual Machine. The user identity references will be ARM resource ids in the form: @@ -4854,9 +4840,9 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, **kwargs ): """ @@ -4942,12 +4928,12 @@ def __init__( os_name: Optional[str] = None, os_version: Optional[str] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -5020,7 +5006,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -5121,12 +5107,12 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, @@ -5197,14 +5183,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5234,12 +5219,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -5252,14 +5237,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5399,7 +5383,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -5430,7 +5414,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs ): """ @@ -5456,7 +5440,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2017_12_01.models.ResourceIdentityType :ivar identity_ids: The list of user identities associated with the virtual machine scale set. @@ -5480,7 +5464,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, identity_ids: Optional[List[str]] = None, **kwargs ): @@ -5488,7 +5472,7 @@ def __init__( :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2017_12_01.models.ResourceIdentityType :keyword identity_ids: The list of user identities associated with the virtual machine scale @@ -5532,7 +5516,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -5592,7 +5576,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2017_12_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -5632,13 +5616,13 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -5656,7 +5640,7 @@ def __init__( ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2017_12_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -5710,7 +5694,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -5751,7 +5735,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -5791,7 +5775,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -5831,7 +5815,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -5852,7 +5836,7 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. Possible values are: - Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", "Premium_LRS". + Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes """ @@ -5864,13 +5848,13 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. Possible values - are: Standard_LRS or Premium_LRS. Possible values include: "Standard_LRS", "Premium_LRS". + are: Standard_LRS or Premium_LRS. Known values are: "Standard_LRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2017_12_01.models.StorageAccountTypes """ @@ -5927,9 +5911,9 @@ def __init__( id: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -6010,8 +5994,8 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -6038,8 +6022,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -6048,13 +6031,13 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk @@ -6084,14 +6067,14 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -6100,8 +6083,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -6110,13 +6092,13 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2017_12_01.models.DiskCreateOptionTypes :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2017_12_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2017_12_01.models.VirtualHardDisk @@ -6213,9 +6195,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -6313,7 +6295,7 @@ def __init__( *, name: str, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, **kwargs ): """ @@ -6414,8 +6396,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -6477,9 +6458,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -6546,11 +6527,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, single_placement_group: Optional[bool] = None, **kwargs @@ -6605,7 +6586,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2017_12_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -6635,13 +6616,13 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -6659,7 +6640,7 @@ def __init__( ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2017_12_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -6725,9 +6706,9 @@ def __init__( name: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -6777,7 +6758,7 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, **kwargs ): """ @@ -6792,7 +6773,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -6819,15 +6800,15 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2017_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -6874,9 +6855,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -6919,7 +6900,7 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, **kwargs ): """ @@ -6958,9 +6939,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -7011,11 +6992,11 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, **kwargs ): @@ -7160,13 +7141,13 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -7383,12 +7364,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -7458,7 +7439,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -7504,12 +7485,12 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low". :vartype priority: str or ~azure.mgmt.compute.v2017_12_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for virtual machines in a low priority - scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values - include: "Deallocate", "Delete". + scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: + "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineEvictionPolicyTypes """ @@ -7528,14 +7509,14 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, **kwargs ): """ @@ -7566,12 +7547,12 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low". :paramtype priority: str or ~azure.mgmt.compute.v2017_12_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for virtual machines in a low priority - scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values - include: "Deallocate", "Delete". + scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: + "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineEvictionPolicyTypes """ @@ -7664,7 +7645,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -7791,15 +7772,15 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -7900,8 +7881,8 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -7946,7 +7927,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -7961,8 +7942,8 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :vartype protocol: str or ~azure.mgmt.compute.v2017_12_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault @@ -7982,14 +7963,14 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2017_12_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/__init__.py index 3ad29360b8dc..c49c1eccc6ce 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/__init__.py @@ -22,6 +22,9 @@ from ._log_analytics_operations import LogAnalyticsOperations from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations +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', 'AvailabilitySetsOperations', @@ -39,3 +42,5 @@ 'LogAnalyticsOperations', 'VirtualMachineRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_availability_sets_operations.py index 04c6396b4477..1d89d26767fc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,9 +123,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -157,9 +160,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +177,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -193,9 +197,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -205,20 +212,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -228,9 +233,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -241,18 +249,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -263,9 +269,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -277,51 +286,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -335,14 +340,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -354,11 +362,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -384,9 +394,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -400,14 +410,17 @@ def update( :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -419,11 +432,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,7 +465,7 @@ def delete( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: + ) -> Optional[_models.OperationStatusResponse]: """Delete an availability set. :param resource_group_name: The name of the resource group. @@ -462,13 +477,16 @@ def delete( :rtype: ~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request( @@ -477,11 +495,13 @@ def delete( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -510,7 +530,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -522,13 +542,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -537,11 +560,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -567,7 +592,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -580,13 +605,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -595,9 +623,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -606,9 +636,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -646,7 +678,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -658,13 +690,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -673,9 +708,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -684,9 +721,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -725,7 +764,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -740,13 +779,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -756,9 +798,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -768,9 +812,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_images_operations.py index 9316bf3dbe9c..d20898661083 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -161,9 +164,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -211,18 +218,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +236,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -243,58 +251,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -306,11 +313,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -340,9 +349,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -363,37 +372,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -410,17 +429,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -432,11 +454,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -466,9 +490,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -489,37 +513,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -537,14 +571,17 @@ def _delete_initial( resource_group_name: str, image_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -553,11 +590,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -586,7 +625,7 @@ def begin_delete( resource_group_name: str, image_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes an Image. :param resource_group_name: The name of the resource group. @@ -607,34 +646,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -654,7 +703,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -668,13 +717,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -684,11 +736,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -714,7 +768,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -724,13 +778,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -739,9 +796,11 @@ def prepare_request(next_link=None): 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: @@ -750,9 +809,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +850,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -798,13 +859,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -812,9 +876,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -822,9 +888,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_log_analytics_operations.py index 1d3ebb24540e..d47170c920a2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_operations.py index 26fc8fd57a62..aae05320d21d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_usage_operations.py index 70617b7746ec..f70f612411ce 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_extension_images_operations.py index da02339a6d12..56ed94661d38 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_extensions_operations.py index e433ffdab9b6..8a6ddbb315ee 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,9 +129,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,18 +147,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -167,9 +170,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -182,61 +188,60 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -249,11 +254,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -284,9 +291,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -313,17 +320,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -331,20 +341,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -362,17 +379,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -385,11 +405,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -416,9 +438,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -445,17 +467,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -463,20 +488,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -495,14 +527,17 @@ def _delete_initial( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -512,11 +547,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -546,7 +583,7 @@ def begin_delete( vm_name: str, vm_extension_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -569,35 +606,45 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -618,7 +665,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -634,13 +681,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -651,11 +701,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_images_operations.py index 777c531c4223..b953b48daff2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_run_commands_operations.py index e9b34a4111e0..7bad81839bf9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_run_commands_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -44,18 +48,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -66,9 +68,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -80,49 +85,45 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -134,13 +135,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -149,9 +153,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -160,9 +166,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -201,7 +209,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -213,13 +221,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -228,11 +239,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_set_extensions_operations.py index 18ae6fe12078..4e8320749734 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,9 +83,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,18 +101,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -122,9 +124,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,20 +142,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -161,9 +164,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -175,59 +181,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -240,11 +245,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -275,9 +282,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -305,17 +312,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -323,20 +333,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -355,14 +372,17 @@ def _delete_initial( vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -372,11 +392,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -406,7 +428,7 @@ def begin_delete( vm_scale_set_name: str, vmss_extension_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to delete the extension. :param resource_group_name: The name of the resource group. @@ -429,35 +451,45 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -478,7 +510,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -494,13 +526,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -511,11 +546,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -542,7 +579,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -556,13 +593,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -572,9 +612,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -584,9 +626,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 56b8aa50ec20..171c3ac2831c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,9 +34,12 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +51,16 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -69,9 +71,12 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -83,18 +88,16 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -105,9 +108,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -119,56 +125,55 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( self, resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_cancel_request_initial( @@ -177,11 +182,13 @@ def _cancel_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -210,7 +217,7 @@ def begin_cancel( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Cancels the current virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -231,34 +238,44 @@ def begin_cancel( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -276,14 +293,17 @@ def _start_os_upgrade_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_os_upgrade_request_initial( @@ -292,11 +312,13 @@ def _start_os_upgrade_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -325,7 +347,7 @@ def begin_start_os_upgrade( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Starts a rolling upgrade to move all virtual machine scale set instances to the latest available Platform Image OS version. Instances which are already running the latest available OS version are not affected. @@ -348,34 +370,44 @@ def begin_start_os_upgrade( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -394,7 +426,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -406,13 +438,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2017_12_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -421,11 +456,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_set_vms_operations.py index 307dc829d51d..f6031bd5415d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,9 +36,12 @@ def build_reimage_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +54,16 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -74,9 +75,12 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -89,18 +93,16 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +114,12 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -127,18 +132,16 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -149,14 +152,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +175,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -196,9 +200,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -211,18 +218,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -234,9 +239,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -249,18 +257,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -272,9 +278,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -287,18 +296,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -313,9 +320,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -327,24 +337,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -356,9 +364,12 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -371,18 +382,16 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -394,9 +403,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -409,18 +421,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -432,9 +442,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -447,18 +460,16 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -470,9 +481,12 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -485,18 +499,16 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -508,9 +520,12 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -523,42 +538,38 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( self, @@ -566,14 +577,17 @@ def _reimage_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_request_initial( @@ -583,11 +597,13 @@ def _reimage_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -617,7 +633,7 @@ def begin_reimage( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -640,35 +656,45 @@ def begin_reimage( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -687,14 +713,17 @@ def _reimage_all_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_reimage_all_request_initial( @@ -704,11 +733,13 @@ def _reimage_all_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -738,7 +769,7 @@ def begin_reimage_all( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Allows you to re-image all the disks ( including data disks ) in the a VM scale set instance. This operation is only supported for managed disks. @@ -762,35 +793,45 @@ def begin_reimage_all( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -809,14 +850,17 @@ def _deallocate_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -826,11 +870,13 @@ def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -860,7 +906,7 @@ def begin_deallocate( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deallocates a specific virtual machine in a VM scale set. Shuts down the virtual machine and releases the compute resources it uses. You are not billed for the compute resources of this virtual machine once it is deallocated. @@ -885,35 +931,45 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -931,17 +987,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -954,11 +1013,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -989,9 +1050,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1017,17 +1078,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1035,20 +1099,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1067,14 +1138,17 @@ def _delete_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -1084,11 +1158,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1118,7 +1194,7 @@ def begin_delete( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1141,35 +1217,45 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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( @@ -1189,7 +1275,7 @@ def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1203,13 +1289,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1219,11 +1308,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1251,7 +1342,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1265,13 +1356,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1281,11 +1375,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1315,7 +1411,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1339,13 +1435,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1358,9 +1457,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1373,9 +1474,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1414,14 +1517,17 @@ def _power_off_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -1431,11 +1537,13 @@ def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1465,7 +1573,7 @@ def begin_power_off( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Power off (stop) a virtual machine in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -1490,35 +1598,45 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1537,14 +1655,17 @@ def _restart_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -1554,11 +1675,13 @@ def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1588,7 +1711,7 @@ def begin_restart( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Restarts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1611,35 +1734,45 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1658,14 +1791,17 @@ def _start_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -1675,11 +1811,13 @@ def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1709,7 +1847,7 @@ def begin_start( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Starts a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1732,35 +1870,45 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1779,14 +1927,17 @@ def _redeploy_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_redeploy_request_initial( @@ -1796,11 +1947,13 @@ def _redeploy_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1830,7 +1983,7 @@ def begin_redeploy( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine in the virtual machine scale set, moves it to a new node, and powers it back on. @@ -1854,35 +2007,45 @@ def begin_redeploy( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1901,14 +2064,17 @@ def _perform_maintenance_initial( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_perform_maintenance_request_initial( @@ -1918,11 +2084,13 @@ def _perform_maintenance_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1952,7 +2120,7 @@ def begin_perform_maintenance( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Performs maintenance on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1975,35 +2143,45 @@ def begin_perform_maintenance( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_sets_operations.py index 482c1e39a262..3d39ccd56a4f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,14 +198,17 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -213,20 +220,18 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -238,14 +243,17 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -257,20 +265,18 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -283,9 +289,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -297,18 +306,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -318,9 +325,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -331,18 +341,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -351,9 +359,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -363,18 +374,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -385,9 +394,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -399,18 +411,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -421,9 +431,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -435,18 +448,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -456,14 +467,17 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -475,20 +489,18 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -500,14 +512,17 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -519,20 +534,18 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -544,14 +557,17 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -563,20 +579,18 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -588,14 +602,17 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -607,20 +624,18 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -632,14 +647,17 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -651,20 +669,18 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -676,14 +692,17 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -695,20 +714,18 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -720,14 +737,17 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -739,20 +759,18 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -764,14 +782,17 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -783,20 +804,18 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -811,9 +830,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( platform_update_domain: int, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -825,59 +847,58 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -889,11 +910,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -923,9 +946,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -948,37 +971,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -995,17 +1028,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -1017,11 +1053,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1047,9 +1085,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1072,37 +1110,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1120,14 +1168,17 @@ def _delete_initial( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -1136,11 +1187,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1169,7 +1222,7 @@ def begin_delete( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes a VM scale set. :param resource_group_name: The name of the resource group. @@ -1190,34 +1243,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -1236,7 +1299,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1248,13 +1311,16 @@ def get( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1263,11 +1329,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1292,17 +1360,20 @@ def _deallocate_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1317,11 +1388,13 @@ def _deallocate_initial( content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1349,9 +1422,9 @@ def begin_deallocate( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and releases the compute resources. You are not billed for the compute resources that this virtual machine scale set deallocates. @@ -1378,37 +1451,47 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **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,17 +1508,20 @@ def _delete_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1447,11 +1533,13 @@ def _delete_instances_initial( content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1479,9 +1567,9 @@ def begin_delete_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Deletes virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1505,37 +1593,47 @@ def begin_delete_instances( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1554,7 +1652,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1566,13 +1664,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1581,11 +1682,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1611,7 +1714,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1623,13 +1726,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1638,9 +1744,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1649,9 +1757,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1688,7 +1798,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1700,13 +1810,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1714,9 +1827,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1724,9 +1839,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1765,7 +1882,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1780,13 +1897,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1796,9 +1916,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1808,9 +1930,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1849,7 +1973,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1863,13 +1987,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1879,9 +2006,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1891,9 +2020,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1930,17 +2061,20 @@ def _power_off_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1955,11 +2089,13 @@ def _power_off_initial( content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1987,9 +2123,9 @@ def begin_power_off( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still attached and you are getting charged for the resources. Instead, use deallocate to release resources and avoid charges. @@ -2016,37 +2152,47 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2063,17 +2209,20 @@ def _restart_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2088,11 +2237,13 @@ def _restart_initial( content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2120,9 +2271,9 @@ def begin_restart( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Restarts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2147,37 +2298,47 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2194,17 +2355,20 @@ def _start_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2219,11 +2383,13 @@ def _start_initial( content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2251,9 +2417,9 @@ def begin_start( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Starts one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2278,37 +2444,47 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2325,17 +2501,20 @@ def _redeploy_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2350,11 +2529,13 @@ def _redeploy_initial( content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2382,9 +2563,9 @@ def begin_redeploy( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, and powers them back on. @@ -2410,37 +2591,47 @@ def begin_redeploy( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2457,17 +2648,20 @@ def _perform_maintenance_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2482,11 +2676,13 @@ def _perform_maintenance_initial( content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2514,9 +2710,9 @@ def begin_perform_maintenance( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances which are not eligible for perform maintenance will be failed. Please refer to best practices for more details: @@ -2544,37 +2740,47 @@ def begin_perform_maintenance( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2591,17 +2797,20 @@ def _update_instances_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.OperationStatusResponse]] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2613,11 +2822,13 @@ def _update_instances_initial( content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2645,9 +2856,9 @@ def begin_update_instances( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. :param resource_group_name: The name of the resource group. @@ -2671,37 +2882,47 @@ def begin_update_instances( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2718,17 +2939,20 @@ def _reimage_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2743,11 +2967,13 @@ def _reimage_initial( content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2775,9 +3001,9 @@ def begin_reimage( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2802,37 +3028,47 @@ def begin_reimage( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2849,17 +3085,20 @@ def _reimage_all_initial( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse]] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2874,11 +3113,13 @@ def _reimage_all_initial( content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2906,9 +3147,9 @@ def begin_reimage_all( self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This operation is only supported for managed disks. @@ -2934,37 +3175,47 @@ def begin_reimage_all( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, 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('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2984,7 +3235,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -3000,13 +3251,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2017_12_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -3016,11 +3270,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_sizes_operations.py index edc7643c4adc..7266e13c56b7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes for a subscription in a location. :param location: The location upon which virtual-machine-sizes is queried. @@ -98,13 +98,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -113,9 +116,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -124,9 +129,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machines_operations.py index 0cd6b4f83b77..af2310f78dc7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2017_12_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +37,12 @@ def build_get_extensions_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_get_extensions_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -74,9 +75,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -87,18 +91,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -108,14 +110,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -127,20 +132,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,14 +155,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,20 +177,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -196,14 +200,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -215,20 +222,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -241,9 +246,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -255,18 +263,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -279,9 +285,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -293,20 +302,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -317,9 +324,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -331,18 +341,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -353,9 +361,12 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -367,18 +378,16 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -389,9 +398,12 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -403,18 +415,16 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -425,9 +435,12 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -439,18 +452,16 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -460,9 +471,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -473,18 +487,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -493,9 +505,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -505,18 +520,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -527,9 +540,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -541,18 +557,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -563,9 +577,12 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -577,18 +594,16 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -599,9 +614,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -613,18 +631,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -635,9 +651,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -649,18 +668,16 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -671,9 +688,12 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -685,18 +705,16 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -707,9 +725,12 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -721,18 +742,16 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -742,14 +761,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -761,46 +783,42 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2017_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.compute.v2017_12_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_extensions( @@ -809,7 +827,7 @@ def get_extensions( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -823,13 +841,16 @@ def get_extensions( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_get_extensions_request( @@ -839,11 +860,13 @@ def get_extensions( api_version=api_version, expand=expand, template_url=self.get_extensions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -869,7 +892,7 @@ def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -881,13 +904,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -896,9 +922,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -907,9 +935,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -946,17 +976,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -968,11 +1001,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1000,9 +1035,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -1026,37 +1061,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1073,17 +1118,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -1095,11 +1143,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1129,9 +1179,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1153,37 +1203,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1200,17 +1260,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1222,11 +1285,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1256,9 +1321,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1280,37 +1345,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1328,14 +1403,17 @@ def _delete_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_delete_request_initial( @@ -1344,11 +1422,13 @@ def _delete_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1377,7 +1457,7 @@ def begin_delete( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to delete a virtual machine. :param resource_group_name: The name of the resource group. @@ -1398,34 +1478,44 @@ def begin_delete( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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( @@ -1445,28 +1535,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1476,11 +1569,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1507,7 +1602,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1519,13 +1614,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2017_12_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1534,11 +1632,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1564,14 +1664,17 @@ def _convert_to_managed_disks_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_convert_to_managed_disks_request_initial( @@ -1580,11 +1683,13 @@ def _convert_to_managed_disks_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1613,7 +1718,7 @@ def begin_convert_to_managed_disks( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Converts virtual machine disks from blob-based to managed disks. Virtual machine must be stop-deallocated before invoking this operation. @@ -1635,34 +1740,44 @@ def begin_convert_to_managed_disks( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1680,14 +1795,17 @@ def _deallocate_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_deallocate_request_initial( @@ -1696,11 +1814,13 @@ def _deallocate_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1729,7 +1849,7 @@ def begin_deallocate( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine and releases the compute resources. You are not billed for the compute resources that this virtual machine uses. @@ -1751,34 +1871,44 @@ def begin_deallocate( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1797,7 +1927,7 @@ def generalize( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.OperationStatusResponse": + ) -> _models.OperationStatusResponse: """Sets the state of the virtual machine to generalized. :param resource_group_name: The name of the resource group. @@ -1809,13 +1939,16 @@ def generalize( :rtype: ~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] request = build_generalize_request( @@ -1824,11 +1957,13 @@ def generalize( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1854,7 +1989,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1867,13 +2002,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1882,9 +2020,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1893,9 +2033,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1932,7 +2074,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1943,13 +2085,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1957,9 +2102,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1967,9 +2114,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2008,7 +2157,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -2023,13 +2172,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2017_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2039,9 +2191,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2051,9 +2205,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2091,14 +2247,17 @@ def _power_off_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_power_off_request_initial( @@ -2107,11 +2266,13 @@ def _power_off_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2140,7 +2301,7 @@ def begin_power_off( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the same provisioned resources. You are still charged for this virtual machine. @@ -2162,34 +2323,44 @@ def begin_power_off( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2207,14 +2378,17 @@ def _restart_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_restart_request_initial( @@ -2223,11 +2397,13 @@ def _restart_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2256,7 +2432,7 @@ def begin_restart( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to restart a virtual machine. :param resource_group_name: The name of the resource group. @@ -2277,34 +2453,44 @@ def begin_restart( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2322,14 +2508,17 @@ def _start_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_start_request_initial( @@ -2338,11 +2527,13 @@ def _start_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2371,7 +2562,7 @@ def begin_start( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to start a virtual machine. :param resource_group_name: The name of the resource group. @@ -2392,34 +2583,44 @@ def begin_start( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2437,14 +2638,17 @@ def _redeploy_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_redeploy_request_initial( @@ -2453,11 +2657,13 @@ def _redeploy_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2486,7 +2692,7 @@ def begin_redeploy( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """Shuts down the virtual machine, moves it to a new node, and powers it back on. :param resource_group_name: The name of the resource group. @@ -2507,34 +2713,44 @@ def begin_redeploy( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2552,14 +2768,17 @@ def _perform_maintenance_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.OperationStatusResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.OperationStatusResponse"]] + ) -> Optional[_models.OperationStatusResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.OperationStatusResponse]] request = build_perform_maintenance_request_initial( @@ -2568,11 +2787,13 @@ def _perform_maintenance_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2601,7 +2822,7 @@ def begin_perform_maintenance( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.OperationStatusResponse"]: + ) -> LROPoller[_models.OperationStatusResponse]: """The operation to perform maintenance on a virtual machine. :param resource_group_name: The name of the resource group. @@ -2622,34 +2843,44 @@ def begin_perform_maintenance( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.OperationStatusResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationStatusResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationStatusResponse"] 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('OperationStatusResponse', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -2666,18 +2897,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2689,11 +2923,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2721,11 +2957,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2734,7 +2970,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2017_12_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2750,36 +2986,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2017_12_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2017-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/_compute_management_client.py index 75554c962ff3..049ec67e2a4e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/_compute_management_client.py @@ -102,24 +102,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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/_compute_management_client.py index 826eea6fdd7f..328503024d9f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/_compute_management_client.py @@ -103,24 +103,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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/__init__.py index 00f6e4823926..b20986f20d10 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/__init__.py @@ -25,6 +25,9 @@ from ._disks_operations import DisksOperations from ._snapshots_operations import SnapshotsOperations +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', 'AvailabilitySetsOperations', @@ -45,3 +48,5 @@ 'DisksOperations', 'SnapshotsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_availability_sets_operations.py index 95822b74e694..70c4e6270abb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2018_04_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2018_04_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_disks_operations.py index 04e77f239fc5..f3e01a116896 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_images_operations.py index d53f0fc20c86..9d896857485b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_log_analytics_operations.py index 99a0c620efee..268831d29d8e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_operations.py index 1dab8a2ddf2f..938cfeea0d59 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_proximity_placement_groups_operations.py index 9b5e223eee65..7c4d864cb56e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2018_04_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2018_04_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -239,7 +253,7 @@ async def get( resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -251,13 +265,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -266,11 +283,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -295,7 +314,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -319,9 +341,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -329,9 +353,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -369,7 +395,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -381,13 +407,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -396,9 +425,11 @@ def prepare_request(next_link=None): 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: @@ -407,9 +438,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_snapshots_operations.py index de8619df0146..255bdda33468 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_usage_operations.py index 47b286a4e517..20da33e1d715 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_extension_images_operations.py index ae3306184178..dee24857381a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_extensions_operations.py index 805f4aa1109d..8c89199066fd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_images_operations.py index 30ed32e2dcad..4e3029d606bb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_run_commands_operations.py index 6e4af6170d09..aace7577591a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -15,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 @@ -24,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,7 +135,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -141,13 +147,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -156,11 +165,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index 6a5489fd4c34..3d1097b711aa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -191,13 +205,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -207,11 +224,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -256,21 +275,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -280,8 +304,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -302,7 +332,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -318,13 +348,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -335,11 +368,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,7 +401,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -380,13 +415,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -396,9 +434,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -408,9 +448,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index fb4d51319ab6..47f838ce4044 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,7 +292,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -273,13 +304,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2018_04_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -288,11 +322,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index 6e19700fc409..f6e14536f72e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, @@ -54,13 +53,16 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_request_initial( @@ -70,11 +72,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,21 +123,26 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -143,8 +152,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -164,13 +179,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -180,11 +198,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -230,21 +250,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -254,8 +279,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -275,13 +306,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -291,11 +325,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -342,21 +378,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -366,8 +407,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -385,17 +432,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -408,11 +458,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -443,9 +495,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -471,17 +523,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -489,20 +544,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -522,13 +584,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -538,11 +603,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -587,21 +654,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -611,8 +683,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -632,7 +710,7 @@ async def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -646,13 +724,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -662,11 +743,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -694,7 +777,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -708,13 +791,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -724,11 +810,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -758,7 +846,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -782,13 +870,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -801,9 +892,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -816,9 +909,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -858,13 +953,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -874,11 +972,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -925,21 +1025,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -949,8 +1054,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -970,13 +1081,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -986,11 +1100,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1035,21 +1151,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1059,8 +1180,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1080,13 +1207,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1096,11 +1226,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1145,21 +1277,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1169,8 +1306,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1190,13 +1333,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1206,11 +1352,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1256,21 +1404,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1280,8 +1433,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1301,13 +1460,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1317,11 +1479,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1366,21 +1530,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1390,8 +1559,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1409,18 +1584,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1433,11 +1611,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1466,11 +1646,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1481,7 +1661,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2018_04_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1498,16 +1678,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1515,20 +1698,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_sets_operations.py index 9ba17fdb1b96..dbba996e11a4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -231,9 +250,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -409,7 +454,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -421,13 +466,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -436,11 +484,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -465,17 +515,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -490,11 +543,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -516,7 +571,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -543,23 +598,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -569,8 +629,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -587,17 +653,20 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -609,11 +678,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,7 +706,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -659,23 +730,28 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +761,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +787,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -717,13 +799,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -732,11 +817,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -762,7 +849,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -774,13 +861,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -789,9 +879,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -800,9 +892,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -839,7 +933,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -851,13 +945,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -865,9 +962,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -875,9 +974,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +1017,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -931,13 +1032,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -947,9 +1051,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -959,9 +1065,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1000,7 +1108,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1014,13 +1122,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1030,9 +1141,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1042,9 +1155,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1081,17 +1196,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1106,11 +1224,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1132,7 +1252,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1159,23 +1279,28 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1185,8 +1310,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1203,17 +1334,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1228,11 +1362,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1254,7 +1390,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1279,23 +1415,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1305,8 +1446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1323,17 +1470,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1348,11 +1498,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1374,7 +1526,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1399,23 +1551,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1425,8 +1582,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1443,17 +1606,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1468,11 +1634,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1494,7 +1662,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1520,23 +1688,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1546,8 +1719,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1564,17 +1743,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1589,11 +1771,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1615,7 +1799,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1643,23 +1827,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1669,8 +1858,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1687,17 +1882,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1709,11 +1907,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1735,7 +1935,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1759,23 +1959,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1785,8 +1990,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1803,17 +2014,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1828,11 +2042,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1854,7 +2070,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set. @@ -1879,23 +2095,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1905,8 +2126,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1923,17 +2150,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1948,11 +2178,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1974,7 +2206,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2000,23 +2232,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2026,8 +2263,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2047,7 +2290,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2063,13 +2306,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2018_04_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2079,11 +2325,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_sizes_operations.py index f9ebe46e94b9..86264d2e096a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes for a subscription in a location. :param location: The location upon which virtual-machine-sizes is queried. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machines_operations.py index 36d56406f8e9..76269726edc8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -337,37 +363,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -384,17 +420,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -406,11 +445,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -440,9 +481,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -465,37 +506,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -514,13 +565,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -529,11 +583,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -575,20 +631,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -598,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -619,28 +686,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -650,11 +720,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -681,7 +753,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -693,13 +765,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -708,11 +783,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -739,13 +816,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -754,11 +834,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -801,20 +883,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -824,8 +911,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -844,13 +937,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -859,11 +955,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -906,20 +1004,25 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -929,8 +1032,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -961,13 +1070,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -976,11 +1088,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1002,7 +1116,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1015,13 +1129,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1030,9 +1147,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1041,9 +1160,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1080,7 +1201,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1091,13 +1212,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1105,9 +1229,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1115,9 +1241,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1156,7 +1284,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1171,13 +1299,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1187,9 +1318,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1199,9 +1332,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1240,13 +1375,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1255,11 +1393,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1302,20 +1442,25 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1325,8 +1470,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1345,13 +1496,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1360,11 +1514,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1406,20 +1562,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1429,8 +1590,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1449,13 +1616,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1464,11 +1634,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1510,20 +1682,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1533,8 +1710,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1553,13 +1736,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1568,11 +1754,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1614,20 +1802,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1637,8 +1830,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1657,13 +1856,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1672,11 +1874,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1718,20 +1922,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1741,8 +1950,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1759,18 +1974,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1782,11 +2000,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1814,11 +2034,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -1827,7 +2047,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2018_04_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1844,36 +2064,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_04_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/__init__.py index 213166a49c44..9a2261e1f014 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/__init__.py @@ -193,7 +193,9 @@ VirtualMachineScaleSetSkuScaleType, VirtualMachineSizeTypes, ) - +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__ = [ 'AccessUri', 'AdditionalUnattendContent', @@ -379,3 +381,5 @@ 'VirtualMachineScaleSetSkuScaleType', 'VirtualMachineSizeTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/_compute_management_client_enums.py index f4e1e7edb3c7..c0ad2ad4b900 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/_compute_management_client_enums.py @@ -7,16 +7,15 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -27,7 +26,7 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -38,7 +37,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COPY = "Copy" RESTORE = "Restore" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -51,7 +50,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -60,7 +59,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -69,7 +68,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -78,21 +77,21 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ GENERALIZED = "Generalized" SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -100,7 +99,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -109,7 +108,7 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -120,14 +119,14 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -136,7 +135,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -144,7 +143,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -152,7 +151,7 @@ class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E PREMIUM_LRS = "Premium_LRS" STANDARD_ZRS = "Standard_ZRS" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -160,7 +159,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. Possible values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. """ @@ -169,7 +168,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PREMIUM_LRS = "Premium_LRS" STANDARD_SSD_LRS = "StandardSSD_LRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -181,7 +180,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -189,7 +188,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -198,7 +197,7 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for virtual machines in a low priority scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview """ @@ -206,7 +205,7 @@ class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for the virtual machines in the scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview """ @@ -214,14 +213,14 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E REGULAR = "Regular" LOW = "Low" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. For more information about virtual machine sizes, see `Sizes for virtual machines `_. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/_models_py3.py index e0ad4a847ae9..cd98b9b1a357 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -52,7 +54,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2018_04_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -73,7 +75,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -86,7 +88,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2018_04_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -154,8 +156,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -362,11 +364,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -421,7 +423,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -503,11 +505,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -692,8 +694,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore". :vartype create_option: str or ~azure.mgmt.compute.v2018_04_01.models.DiskCreateOption :ivar storage_account_id: If createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in a @@ -724,16 +726,16 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, **kwargs ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore". + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore". :paramtype create_option: str or ~azure.mgmt.compute.v2018_04_01.models.DiskCreateOption :keyword storage_account_id: If createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in @@ -776,8 +778,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -788,7 +789,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2018_04_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -819,14 +820,14 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ @@ -845,8 +846,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -857,7 +857,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2018_04_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -923,7 +923,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -962,7 +962,7 @@ class Disk(Resource): :vartype zones: list[str] :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1010,12 +1010,12 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - creation_data: Optional["CreationData"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ @@ -1027,7 +1027,7 @@ def __init__( :paramtype sku: ~azure.mgmt.compute.v2018_04_01.models.DiskSku :keyword zones: The Logical zone list for Disk. :paramtype zones: list[str] - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1073,8 +1073,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -1116,8 +1116,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1160,7 +1160,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -1181,8 +1181,7 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS". :vartype name: str or ~azure.mgmt.compute.v2018_04_01.models.StorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -1200,11 +1199,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "StorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS". :paramtype name: str or ~azure.mgmt.compute.v2018_04_01.models.StorageAccountTypes """ @@ -1220,7 +1219,7 @@ class DiskUpdate(msrest.serialization.Model): :vartype tags: dict[str, str] :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, or StandardSSD_LRS. :vartype sku: ~azure.mgmt.compute.v2018_04_01.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -1243,10 +1242,10 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ @@ -1254,7 +1253,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, or StandardSSD_LRS. :paramtype sku: ~azure.mgmt.compute.v2018_04_01.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -1296,8 +1295,8 @@ def __init__( self, *, enabled: Optional[bool] = None, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -1323,7 +1322,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read". + :ivar access: Required. Known values are: "None", "Read". :vartype access: str or ~azure.mgmt.compute.v2018_04_01.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -1342,12 +1341,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read". + :keyword access: Required. Known values are: "None", "Read". :paramtype access: str or ~azure.mgmt.compute.v2018_04_01.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -1370,8 +1369,8 @@ class HardwareProfile(msrest.serialization.Model): :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -1416,7 +1415,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -1430,8 +1429,8 @@ def __init__( :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -1521,8 +1520,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, **kwargs ): """ @@ -1559,16 +1558,15 @@ class ImageDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Possible values include: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS". + values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Known values are: "Standard_LRS", + "Premium_LRS", "StandardSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2018_04_01.models.StorageAccountTypes """ @@ -1591,12 +1589,12 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ @@ -1613,15 +1611,14 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Possible values include: + Possible values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2018_04_01.models.StorageAccountTypes @@ -1702,7 +1699,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -1725,10 +1722,10 @@ class ImageOSDisk(msrest.serialization.Model): :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemStateTypes :ivar snapshot: The snapshot. :vartype snapshot: ~azure.mgmt.compute.v2018_04_01.models.SubResource @@ -1739,16 +1736,15 @@ class ImageOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Possible values include: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS". + values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Known values are: "Standard_LRS", + "Premium_LRS", "StandardSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2018_04_01.models.StorageAccountTypes """ @@ -1772,24 +1768,23 @@ class ImageOSDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemStateTypes :keyword snapshot: The snapshot. :paramtype snapshot: ~azure.mgmt.compute.v2018_04_01.models.SubResource @@ -1800,15 +1795,14 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Possible values include: + Possible values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2018_04_01.models.StorageAccountTypes @@ -1938,8 +1932,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -1994,8 +1988,8 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, **kwargs ): """ @@ -2049,7 +2043,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2018_04_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -2071,7 +2065,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -2080,7 +2074,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2018_04_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -2121,7 +2115,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -2160,7 +2154,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -2200,7 +2194,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -2239,7 +2233,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -2272,7 +2266,7 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, **kwargs ): """ @@ -2311,7 +2305,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -2465,8 +2459,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2018_04_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -2491,7 +2485,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -2507,8 +2501,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2018_04_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -2530,8 +2524,8 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. Possible - values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Possible values include: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS". + values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Known values are: "Standard_LRS", + "Premium_LRS", "StandardSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2018_04_01.models.StorageAccountTypes """ @@ -2545,14 +2539,14 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. - Possible values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Possible values include: + Possible values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2018_04_01.models.StorageAccountTypes @@ -2610,7 +2604,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -2630,8 +2624,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -2647,8 +2641,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -2659,7 +2652,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2018_04_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -2689,23 +2682,23 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -2721,8 +2714,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -2733,7 +2725,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2018_04_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -2760,8 +2752,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes """ @@ -2776,12 +2768,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -2866,9 +2858,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -3009,7 +3001,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2018_04_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -3050,7 +3042,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, **kwargs ): """ @@ -3061,7 +3053,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2018_04_01.models.ProximityPlacementGroupType """ @@ -3095,7 +3087,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -3235,7 +3227,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_resource_name: Group query result by Resource Name. :vartype group_by_resource_name: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2018_04_01.models.IntervalInMins """ @@ -3262,7 +3254,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -3283,7 +3275,7 @@ def __init__( :keyword group_by_resource_name: Group query result by Resource Name. :paramtype group_by_resource_name: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2018_04_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, **kwargs) @@ -3452,13 +3444,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2018_04_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2018_04_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -3571,8 +3563,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -3601,7 +3592,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -3611,8 +3602,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -3636,8 +3626,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -3673,11 +3662,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -3685,8 +3674,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -3732,7 +3720,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -3813,7 +3801,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -3896,7 +3884,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -3973,7 +3961,7 @@ class Snapshot(Resource): :vartype sku: ~azure.mgmt.compute.v2018_04_01.models.SnapshotSku :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -4020,11 +4008,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ @@ -4034,7 +4022,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2018_04_01.models.SnapshotSku - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -4082,7 +4070,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -4103,8 +4091,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2018_04_01.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -4122,12 +4109,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2018_04_01.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -4142,7 +4128,7 @@ class SnapshotUpdate(msrest.serialization.Model): :vartype tags: dict[str, str] :ivar sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :vartype sku: ~azure.mgmt.compute.v2018_04_01.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -4165,10 +4151,10 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ @@ -4176,7 +4162,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2018_04_01.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -4233,7 +4219,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -4315,9 +4301,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -4483,7 +4469,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2018_04_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2018_04_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2018_04_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -4530,7 +4516,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2018_04_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -4570,8 +4556,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2018_04_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -4594,10 +4580,10 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, automatic_os_upgrade: Optional[bool] = None, - auto_os_upgrade_policy: Optional["AutoOSUpgradePolicy"] = None, + auto_os_upgrade_policy: Optional["_models.AutoOSUpgradePolicy"] = None, **kwargs ): """ @@ -4605,8 +4591,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2018_04_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -4663,7 +4649,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -4785,8 +4771,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -4939,16 +4925,16 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -5043,8 +5029,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -5240,7 +5226,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -5305,7 +5291,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -5442,8 +5428,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -5480,7 +5466,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -5612,8 +5598,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2018_04_01.models.ResourceIdentityType :ivar identity_ids: The list of user identities associated with the Virtual Machine. The user identity references will be ARM resource ids in the form: @@ -5636,15 +5622,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, identity_ids: Optional[List[str]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2018_04_01.models.ResourceIdentityType :keyword identity_ids: The list of user identities associated with the Virtual Machine. The user identity references will be ARM resource ids in the form: @@ -5760,9 +5746,9 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, **kwargs ): """ @@ -5848,12 +5834,12 @@ def __init__( os_name: Optional[str] = None, os_version: Optional[str] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -5926,7 +5912,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -6032,17 +6018,17 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -6114,14 +6100,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2018_04_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -6151,12 +6136,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -6169,14 +6154,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2018_04_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -6316,7 +6300,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -6347,7 +6331,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs ): """ @@ -6373,7 +6357,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2018_04_01.models.ResourceIdentityType :ivar identity_ids: The list of user identities associated with the virtual machine scale set. @@ -6397,7 +6381,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, identity_ids: Optional[List[str]] = None, **kwargs ): @@ -6405,7 +6389,7 @@ def __init__( :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2018_04_01.models.ResourceIdentityType :keyword identity_ids: The list of user identities associated with the virtual machine scale @@ -6449,7 +6433,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -6509,7 +6493,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2018_04_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -6549,13 +6533,13 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -6573,7 +6557,7 @@ def __init__( ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2018_04_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -6659,7 +6643,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -6700,7 +6684,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -6740,7 +6724,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -6780,7 +6764,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -6801,7 +6785,7 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. Possible values are: - Standard_LRS, Premium_LRS, and StandardSSD_LRS. Possible values include: "Standard_LRS", + Standard_LRS, Premium_LRS, and StandardSSD_LRS. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2018_04_01.models.StorageAccountTypes @@ -6814,13 +6798,13 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. Possible values - are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Possible values include: "Standard_LRS", + are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2018_04_01.models.StorageAccountTypes @@ -6878,9 +6862,9 @@ def __init__( id: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -6961,8 +6945,8 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -6989,8 +6973,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -6999,8 +6982,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2018_04_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of the operating system disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. @@ -7008,8 +6991,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2018_04_01.models.VirtualHardDisk @@ -7040,15 +7023,15 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -7057,8 +7040,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -7067,8 +7049,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2018_04_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of the operating system disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. @@ -7077,7 +7059,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_04_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2018_04_01.models.VirtualHardDisk @@ -7175,9 +7157,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -7278,8 +7260,8 @@ def __init__( *, name: str, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, **kwargs ): """ @@ -7383,8 +7365,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -7446,9 +7427,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -7520,14 +7501,14 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, single_placement_group: Optional[bool] = None, - proximity_placement_group: Optional["SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -7585,7 +7566,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2018_04_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -7615,13 +7596,13 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -7639,7 +7620,7 @@ def __init__( ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2018_04_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -7705,9 +7686,9 @@ def __init__( name: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -7757,7 +7738,7 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, **kwargs ): """ @@ -7772,7 +7753,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -7804,16 +7785,16 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_04_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -7865,9 +7846,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -7910,7 +7891,7 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, **kwargs ): """ @@ -7949,9 +7930,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -8002,11 +7983,11 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, **kwargs ): @@ -8155,13 +8136,13 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -8379,12 +8360,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -8454,7 +8435,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -8500,12 +8481,12 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low". :vartype priority: str or ~azure.mgmt.compute.v2018_04_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for virtual machines in a low priority - scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values - include: "Deallocate", "Delete". + scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: + "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineEvictionPolicyTypes """ @@ -8524,14 +8505,14 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, **kwargs ): """ @@ -8562,12 +8543,12 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low". :paramtype priority: str or ~azure.mgmt.compute.v2018_04_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for virtual machines in a low priority - scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values - include: "Deallocate", "Delete". + scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: + "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineEvictionPolicyTypes """ @@ -8660,7 +8641,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -8792,16 +8773,16 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -8907,8 +8888,8 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -8953,7 +8934,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -8968,8 +8949,8 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :vartype protocol: str or ~azure.mgmt.compute.v2018_04_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault @@ -8989,14 +8970,14 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2018_04_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/__init__.py index 00f6e4823926..b20986f20d10 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/__init__.py @@ -25,6 +25,9 @@ from ._disks_operations import DisksOperations from ._snapshots_operations import SnapshotsOperations +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', 'AvailabilitySetsOperations', @@ -45,3 +48,5 @@ 'DisksOperations', 'SnapshotsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_availability_sets_operations.py index c3350137b436..15f4ce8ff5b0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +190,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -199,20 +205,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -235,18 +242,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -257,9 +262,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -271,51 +279,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -329,14 +333,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2018_04_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -348,11 +355,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -378,9 +387,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -394,14 +403,17 @@ def update( :rtype: ~azure.mgmt.compute.v2018_04_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -413,11 +425,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,13 +470,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -471,11 +488,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -498,7 +517,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -510,13 +529,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -525,11 +547,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -555,7 +579,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -568,13 +592,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -583,9 +610,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +623,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -634,7 +665,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -646,13 +677,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +695,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -672,9 +708,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -713,7 +751,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -728,13 +766,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -756,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_disks_operations.py index 4d1e5531c93f..ea440976e253 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_images_operations.py index 55fd4ef3e06b..d1de822a3014 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -155,9 +157,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +174,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -192,9 +195,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -205,18 +211,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +229,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -237,58 +244,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -300,11 +306,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -334,9 +342,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -357,37 +365,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -404,17 +422,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -426,11 +447,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -460,9 +483,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -483,37 +506,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -532,13 +565,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -547,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,20 +631,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -616,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -637,7 +686,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -651,13 +700,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -667,11 +719,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -707,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -722,9 +779,11 @@ def prepare_request(next_link=None): 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: @@ -733,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -772,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -781,13 +842,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -805,9 +871,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_log_analytics_operations.py index 75cf8c371576..de32d579301b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_operations.py index a7fb20a6acb1..7c2960134e2a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_proximity_placement_groups_operations.py index 3e5936239f63..b4cb7f1ca0ba 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -185,9 +188,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -197,18 +203,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -218,9 +222,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -231,51 +238,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -289,14 +292,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2018_04_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -308,11 +314,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -342,9 +350,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -358,14 +366,17 @@ def update( :rtype: ~azure.mgmt.compute.v2018_04_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -377,11 +388,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -420,13 +433,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -435,11 +451,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -462,7 +480,7 @@ def get( resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -474,13 +492,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -489,11 +510,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -518,7 +541,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -528,13 +551,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -542,9 +568,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -552,9 +580,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -592,7 +622,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -604,13 +634,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -619,9 +652,11 @@ def prepare_request(next_link=None): 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: @@ -630,9 +665,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_snapshots_operations.py index 46eb2770ecfe..067354f7cae2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_usage_operations.py index e0fba0516b68..afc8c48e2a79 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_extension_images_operations.py index bfb81bc604a1..e224c11a637d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_extensions_operations.py index 9997c61c4297..b2de83c61a34 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,8 +129,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -141,13 +144,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -161,9 +163,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -176,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -202,9 +205,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -216,61 +222,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -283,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -318,9 +325,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -347,17 +354,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -365,20 +375,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -396,17 +413,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -419,11 +439,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,9 +472,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -479,17 +501,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -497,20 +522,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -530,13 +562,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -546,11 +581,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,21 +632,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -619,8 +661,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -641,7 +689,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -657,13 +705,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -674,11 +725,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -706,7 +759,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -720,13 +773,16 @@ def list( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -736,11 +792,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_images_operations.py index e904886ea535..659c503f414d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_run_commands_operations.py index 009e309c302f..0f4cac164586 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_run_commands_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -44,18 +48,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -66,9 +68,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -80,49 +85,45 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -134,13 +135,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -149,9 +153,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -160,9 +166,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -201,7 +209,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -213,13 +221,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -228,11 +239,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_set_extensions_operations.py index 6a6eea802bcd..155e33358912 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,8 +83,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -96,13 +98,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -116,9 +117,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +135,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -155,9 +157,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -169,59 +174,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -234,11 +238,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -269,9 +275,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -299,17 +305,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -317,20 +326,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -350,13 +366,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -366,11 +385,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -415,21 +436,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -439,8 +465,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -461,7 +493,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -477,13 +509,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -494,11 +529,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -525,7 +562,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -539,13 +576,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -555,9 +595,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_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,9 +609,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 8f1836874040..5a081c21d766 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,8 +34,9 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -46,13 +48,12 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -63,8 +64,9 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -76,13 +78,12 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -93,9 +94,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -107,42 +111,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -150,13 +150,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -165,11 +168,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -211,20 +216,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -234,8 +244,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -254,13 +270,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -269,11 +288,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -317,20 +338,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -340,8 +366,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -360,7 +392,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -372,13 +404,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2018_04_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -387,11 +422,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_set_vms_operations.py index 9e0e84c16ec4..130a33cff04a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,8 +36,9 @@ def build_reimage_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -50,13 +51,12 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -68,8 +68,9 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -82,13 +83,12 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -100,8 +100,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -114,13 +115,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -131,14 +131,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +154,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -178,8 +179,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -192,13 +194,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -210,9 +211,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -225,18 +229,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -248,9 +250,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -263,18 +268,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -289,9 +292,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -303,24 +309,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -332,8 +336,9 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -346,13 +351,12 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -364,8 +368,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -378,13 +383,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -396,8 +400,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -410,13 +415,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -428,8 +432,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -442,13 +447,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -460,8 +464,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -474,13 +479,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -491,14 +495,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -511,46 +518,42 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, @@ -559,13 +562,16 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_request_initial( @@ -575,11 +581,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -624,21 +632,26 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -648,8 +661,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -669,13 +688,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -685,11 +707,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -735,21 +759,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -759,8 +788,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -780,13 +815,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -796,11 +834,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -847,21 +887,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -871,8 +916,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -890,17 +941,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -913,11 +967,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -948,9 +1004,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -976,17 +1032,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -994,20 +1053,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1027,13 +1093,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1043,11 +1112,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1092,21 +1163,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1116,8 +1192,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1137,7 +1219,7 @@ def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1151,13 +1233,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1167,11 +1252,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1199,7 +1286,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1213,13 +1300,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1229,11 +1319,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1263,7 +1355,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1287,13 +1379,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1306,9 +1401,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1321,9 +1418,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1363,13 +1462,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1379,11 +1481,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1430,21 +1534,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1454,8 +1563,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1475,13 +1590,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1491,11 +1609,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1540,21 +1660,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1564,8 +1689,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1585,13 +1716,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1601,11 +1735,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1650,21 +1786,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1674,8 +1815,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1695,13 +1842,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1711,11 +1861,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1761,21 +1913,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1785,8 +1942,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1806,13 +1969,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1822,11 +1988,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1871,21 +2039,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1895,8 +2068,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1914,18 +2093,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1938,11 +2120,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1971,11 +2155,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1986,7 +2170,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2018_04_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2002,16 +2186,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2019,20 +2206,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_sets_operations.py index d83a7c98ea93..1e0de610dff8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,18 +172,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -188,13 +191,15 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -206,19 +211,17 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -230,13 +233,15 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -248,19 +253,17 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -273,9 +276,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -287,18 +293,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -308,9 +312,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -321,18 +328,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -341,9 +346,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -353,18 +361,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -375,9 +381,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -389,18 +398,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -411,9 +418,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -425,18 +435,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -446,13 +454,15 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -464,19 +474,17 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -488,13 +496,15 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -506,19 +516,17 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -530,13 +538,15 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -548,19 +558,17 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -572,13 +580,15 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -590,19 +600,17 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -614,13 +622,15 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -632,19 +642,17 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -656,13 +664,15 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -674,19 +684,17 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -698,13 +706,15 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -716,19 +726,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -740,13 +748,15 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -758,19 +768,17 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -785,9 +793,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( platform_update_domain: int, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -799,59 +810,58 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -863,11 +873,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -897,9 +909,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -922,37 +934,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -969,17 +991,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -991,11 +1016,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1021,9 +1048,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1046,37 +1073,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1095,13 +1132,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1110,11 +1150,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1156,20 +1198,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1179,8 +1226,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1199,7 +1252,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1211,13 +1264,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1226,11 +1282,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1255,17 +1313,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1280,11 +1341,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1306,7 +1369,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1333,23 +1396,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1359,8 +1427,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1377,17 +1451,20 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1399,11 +1476,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1425,7 +1504,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -1449,23 +1528,28 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1475,8 +1559,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1495,7 +1585,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1507,13 +1597,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1522,11 +1615,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1552,7 +1647,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1564,13 +1659,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1579,9 +1677,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1590,9 +1690,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1629,7 +1731,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1641,13 +1743,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1655,9 +1760,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1665,9 +1772,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1706,7 +1815,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1721,13 +1830,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1737,9 +1849,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1749,9 +1863,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1790,7 +1906,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1804,13 +1920,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1820,9 +1939,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1832,9 +1953,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1871,17 +1994,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1896,11 +2022,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1922,7 +2050,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1949,23 +2077,28 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1975,8 +2108,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1993,17 +2132,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2018,11 +2160,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2044,7 +2188,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2069,23 +2213,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2095,8 +2244,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2113,17 +2268,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2138,11 +2296,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2164,7 +2324,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2189,23 +2349,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2215,8 +2380,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2233,17 +2404,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2258,11 +2432,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2284,7 +2460,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2310,23 +2486,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2336,8 +2517,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2354,17 +2541,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2379,11 +2569,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2405,7 +2597,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2433,23 +2625,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2459,8 +2656,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2477,17 +2680,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2499,11 +2705,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2525,7 +2733,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2549,23 +2757,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2575,8 +2788,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2593,17 +2812,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2618,11 +2840,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2644,7 +2868,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set. @@ -2669,23 +2893,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2695,8 +2924,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2713,17 +2948,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2738,11 +2976,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2764,7 +3004,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2790,23 +3030,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2816,8 +3061,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2837,7 +3088,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2853,13 +3104,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2018_04_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2869,11 +3123,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_sizes_operations.py index e24e29fc9159..d97d01789d9d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes for a subscription in a location. :param location: The location upon which virtual-machine-sizes is queried. @@ -98,13 +98,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -113,9 +116,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -124,9 +129,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machines_operations.py index 02913189e499..abb9a7bd11a5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_04_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -201,8 +205,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -214,13 +219,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -233,9 +237,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -247,20 +254,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -271,9 +276,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -285,18 +293,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -307,8 +313,9 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -320,13 +327,12 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -337,8 +343,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -350,13 +357,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -367,8 +373,9 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -380,13 +387,12 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -396,9 +402,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -409,18 +418,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -429,9 +436,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -441,18 +451,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -463,9 +471,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -477,18 +488,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -499,8 +508,9 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -512,13 +522,12 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -529,8 +538,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -542,13 +552,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -559,8 +568,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -572,13 +582,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -589,8 +598,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -602,13 +612,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -619,8 +628,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -632,13 +642,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -648,14 +657,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -667,53 +679,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2018_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_04_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -725,13 +733,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -740,9 +751,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -751,9 +764,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -790,17 +805,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -812,11 +830,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -844,9 +864,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -870,37 +890,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -917,17 +947,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -939,11 +972,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -973,9 +1008,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -997,37 +1032,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1044,17 +1089,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1066,11 +1114,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1100,9 +1150,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1124,37 +1174,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1173,13 +1233,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1188,11 +1251,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1234,20 +1299,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1257,8 +1327,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1278,28 +1354,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1309,11 +1388,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1340,7 +1421,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1352,13 +1433,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2018_04_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1367,11 +1451,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1398,13 +1484,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1413,11 +1502,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1460,20 +1551,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1483,8 +1579,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1503,13 +1605,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -1518,11 +1623,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1565,20 +1672,25 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1588,8 +1700,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1620,13 +1738,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1635,11 +1756,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1661,7 +1784,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1674,13 +1797,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1689,9 +1815,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1700,9 +1828,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1739,7 +1869,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1750,13 +1880,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1764,9 +1897,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1774,9 +1909,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1815,7 +1952,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1830,13 +1967,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_04_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1846,9 +1986,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1858,9 +2000,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1899,13 +2043,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements vm_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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1914,11 +2061,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1961,20 +2110,25 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1984,8 +2138,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2004,13 +2164,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2019,11 +2182,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2065,20 +2230,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2088,8 +2258,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2108,13 +2284,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2123,11 +2302,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2169,20 +2350,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2192,8 +2378,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2212,13 +2404,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2227,11 +2422,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2273,20 +2470,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2296,8 +2498,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2316,13 +2524,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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', "2018-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2331,11 +2542,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2377,20 +2590,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2400,8 +2618,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2418,18 +2642,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2441,11 +2668,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2473,11 +2702,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2486,7 +2715,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2018_04_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2502,36 +2731,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_04_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/_compute_management_client.py index 1975d12ce50e..31adfdaed5a9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/_compute_management_client.py @@ -109,27 +109,69 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/_compute_management_client.py index 82dc2189549f..0cc19fa31ce7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/_compute_management_client.py @@ -110,27 +110,69 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/__init__.py index ae7010225ed5..7a15b1929df9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/__init__.py @@ -28,6 +28,9 @@ from ._disks_operations import DisksOperations from ._snapshots_operations import SnapshotsOperations +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', 'AvailabilitySetsOperations', @@ -51,3 +54,5 @@ 'DisksOperations', 'SnapshotsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_availability_sets_operations.py index ccc7c15f865f..64e5217b95c8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2018_06_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2018_06_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_disks_operations.py index 16c645dea0ed..4d5f801a3638 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_galleries_operations.py index 6382d5a792d4..5e912f9162d4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleriesOperations: - """GalleriesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -184,7 +198,7 @@ async def get( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -196,13 +210,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -211,11 +228,13 @@ async def get( gallery_name=gallery_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,13 +261,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -257,11 +279,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -303,20 +327,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -326,8 +355,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -345,7 +380,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -356,13 +391,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -371,9 +409,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -382,9 +422,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -421,7 +463,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -430,13 +472,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -444,9 +489,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -454,9 +501,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_gallery_image_versions_operations.py index 11f9f5b33e34..54339c8379be 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImageVersionsOperations: - """GalleryImageVersionsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Create or update a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -151,17 +155,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -170,20 +177,27 @@ async def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -205,7 +219,7 @@ async def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -225,13 +239,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -243,11 +260,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -276,13 +295,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -293,11 +315,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,22 +371,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -372,8 +401,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -393,7 +428,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageVersionList"]: + ) -> AsyncIterable[_models.GalleryImageVersionList]: """List gallery Image Versions in a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -411,13 +446,16 @@ def list_by_gallery_image( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -428,9 +466,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -441,9 +481,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_gallery_images_operations.py index b06c76dff0da..19bbccb2943a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImagesOperations: - """GalleryImagesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Create or update a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -160,20 +167,27 @@ async def begin_create_or_update( 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('GalleryImage', 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( @@ -193,7 +207,7 @@ async def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -208,13 +222,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -224,11 +241,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -256,13 +275,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -272,11 +294,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -322,21 +346,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -346,8 +375,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -366,7 +401,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageList"]: + ) -> AsyncIterable[_models.GalleryImageList]: """List gallery Image Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -380,13 +415,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -396,9 +434,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -408,9 +448,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_images_operations.py index 0bbdf067f7bf..9e1c4e6d27cd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_log_analytics_operations.py index 7cadeaae4f08..e9db67561265 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_operations.py index c7eae79ef24a..0a5a90de85cb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_proximity_placement_groups_operations.py index aa987afcd09d..7a789fa9794b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2018_06_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2018_06_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -239,7 +253,7 @@ async def get( resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -251,13 +265,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -266,11 +283,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -295,7 +314,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -319,9 +341,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -329,9 +353,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -369,7 +395,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -381,13 +407,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -396,9 +425,11 @@ def prepare_request(next_link=None): 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: @@ -407,9 +438,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_snapshots_operations.py index e45eb11a942e..7131b90659c7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_usage_operations.py index 72a931389d24..5b18c23c4742 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_extension_images_operations.py index ee0bf71f0af8..6d666053de12 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_extensions_operations.py index d080473cce98..739af03bcad0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_images_operations.py index ef72a86e5331..ace719c09d5f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_run_commands_operations.py index fffa22da5359..8e4cdb9bd0c2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -15,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 @@ -24,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,7 +135,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -141,13 +147,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -156,11 +165,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index 42e9f460cd39..4f152168f4a6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -191,13 +205,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -207,11 +224,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -256,21 +275,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -280,8 +304,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -302,7 +332,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -318,13 +348,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -335,11 +368,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,7 +401,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -380,13 +415,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -396,9 +434,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -408,9 +448,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 12f3c3ecf317..a464a839c0a0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,13 +292,16 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu vm_scale_set_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -276,11 +310,13 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,20 +360,25 @@ async def begin_start_extension_upgrade( # pylint: disable=inconsistent-return- :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_extension_upgrade_initial( + raw_result = await self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -347,8 +388,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -367,7 +414,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -379,13 +426,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2018_06_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -394,11 +444,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index 7d8d8facb304..c5e29bf7a892 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -78,11 +80,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -132,17 +136,20 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -150,6 +157,8 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,13 +195,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -196,11 +214,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,21 +266,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -270,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -291,13 +322,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -307,11 +341,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,21 +394,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -382,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -401,17 +448,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -424,11 +474,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,9 +511,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -487,17 +539,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -505,20 +560,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -538,13 +600,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -554,11 +619,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -603,21 +670,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -627,8 +699,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -648,7 +726,7 @@ async def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -662,13 +740,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -678,11 +759,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -710,7 +793,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -724,13 +807,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -740,11 +826,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -774,7 +862,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -798,13 +886,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -817,9 +908,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -832,9 +925,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -874,13 +969,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -890,11 +988,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -941,21 +1041,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -965,8 +1070,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -986,13 +1097,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1002,11 +1116,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1051,21 +1167,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1075,8 +1196,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1096,13 +1223,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1112,11 +1242,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1161,21 +1293,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1185,8 +1322,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1206,13 +1349,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1222,11 +1368,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1272,21 +1420,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1296,8 +1449,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1317,13 +1476,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1333,11 +1495,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1382,21 +1546,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1406,8 +1575,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1425,18 +1600,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1449,11 +1627,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1482,11 +1662,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1497,7 +1677,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2018_06_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1514,16 +1694,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1531,20 +1714,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_sets_operations.py index 52020c5d5d45..aa5b6a0d487f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -231,9 +250,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -409,7 +454,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -421,13 +466,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -436,11 +484,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -465,17 +515,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -490,11 +543,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -516,7 +571,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -543,23 +598,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -569,8 +629,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -587,17 +653,20 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -609,11 +678,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,7 +706,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -659,23 +730,28 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +761,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +787,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -717,13 +799,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -732,11 +817,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -762,7 +849,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -774,13 +861,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -789,9 +879,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -800,9 +892,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -839,7 +933,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -851,13 +945,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -865,9 +962,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -875,9 +974,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +1017,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -931,13 +1032,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -947,9 +1051,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -959,9 +1065,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1000,7 +1108,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1014,13 +1122,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1030,9 +1141,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1042,9 +1155,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1081,17 +1196,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1106,11 +1224,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1132,7 +1252,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1159,23 +1279,28 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1185,8 +1310,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1203,17 +1334,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1228,11 +1362,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1254,7 +1390,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1279,23 +1415,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1305,8 +1446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1323,17 +1470,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1348,11 +1498,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1374,7 +1526,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1399,23 +1551,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1425,8 +1582,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1443,17 +1606,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1468,11 +1634,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1494,7 +1662,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1520,23 +1688,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1546,8 +1719,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1564,17 +1743,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1589,11 +1771,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1615,7 +1799,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1643,23 +1827,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1669,8 +1858,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1687,17 +1882,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1709,11 +1907,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1735,7 +1935,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1759,23 +1959,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1785,8 +1990,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1803,17 +2014,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -1828,11 +2042,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1854,7 +2070,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -1880,23 +2096,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1906,8 +2127,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1924,17 +2151,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1949,11 +2179,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1975,7 +2207,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2001,23 +2233,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2027,8 +2264,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2048,7 +2291,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2064,13 +2307,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2018_06_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2080,11 +2326,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_sizes_operations.py index 1fcf0b5f4155..16bb2a5a7fa7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machines_operations.py index c148071aad0d..472c5f13939b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -337,37 +363,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -384,17 +420,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -406,11 +445,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -440,9 +481,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -465,37 +506,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -514,13 +565,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -529,11 +583,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -575,20 +631,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -598,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -619,28 +686,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -650,11 +720,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -681,7 +753,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -693,13 +765,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -708,11 +783,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -739,13 +816,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -754,11 +834,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -801,20 +883,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -824,8 +911,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -844,13 +937,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -859,11 +955,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -906,20 +1004,25 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -929,8 +1032,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -961,13 +1070,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -976,11 +1088,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1002,7 +1116,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1015,13 +1129,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1030,9 +1147,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1041,9 +1160,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1080,7 +1201,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1091,13 +1212,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1105,9 +1229,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1115,9 +1241,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1156,7 +1284,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1171,13 +1299,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1187,9 +1318,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1199,9 +1332,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1240,13 +1375,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1255,11 +1393,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1302,20 +1442,25 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1325,8 +1470,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1345,13 +1496,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1360,11 +1514,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1406,20 +1562,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1429,8 +1590,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1449,13 +1616,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1464,11 +1634,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1510,20 +1682,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1533,8 +1710,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1553,13 +1736,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1568,11 +1754,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1614,20 +1802,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1637,8 +1830,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1655,17 +1854,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -1680,11 +1882,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1706,7 +1910,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -1730,23 +1934,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -1756,8 +1965,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1776,13 +1991,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1791,11 +2009,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1837,20 +2057,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1860,8 +2085,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1878,18 +2109,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1901,11 +2135,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1933,11 +2169,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -1946,7 +2182,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2018_06_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1963,36 +2199,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_06_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/__init__.py index 89afff2c5dcc..83cb77ef9370 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/__init__.py @@ -233,7 +233,9 @@ VirtualMachineScaleSetSkuScaleType, VirtualMachineSizeTypes, ) - +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__ = [ 'AccessUri', 'AdditionalCapabilities', @@ -459,3 +461,5 @@ 'VirtualMachineScaleSetSkuScaleType', 'VirtualMachineSizeTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/_compute_management_client_enums.py index 75a0432d3f90..a8591c2a21bc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/_compute_management_client_enums.py @@ -7,16 +7,15 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" -class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the aggregated replication status based on all the regional replication status flags. """ @@ -25,7 +24,7 @@ class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, En COMPLETED = "Completed" FAILED = "Failed" -class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. """ @@ -33,7 +32,7 @@ class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CLASSIC = "Classic" ALIGNED = "Aligned" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -44,13 +43,13 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DiffDiskOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk option for operating system disk. """ LOCAL = "Local" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -61,7 +60,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COPY = "Copy" RESTORE = "Restore" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -74,7 +73,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -83,7 +82,7 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) STANDARD_SSD_LRS = "StandardSSD_LRS" ULTRA_SSD_LRS = "UltraSSD_LRS" -class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImagePropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -94,7 +93,7 @@ class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnum DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImageVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -105,7 +104,7 @@ class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensit DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -116,7 +115,7 @@ class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, DELETING = "Deleting" MIGRATING = "Migrating" -class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite' """ @@ -124,7 +123,7 @@ class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -133,7 +132,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -142,7 +141,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -151,21 +150,21 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ GENERALIZED = "Generalized" SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -173,7 +172,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -182,7 +181,7 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the regional replication state. """ @@ -191,11 +190,11 @@ class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAILED = "Failed" -class ReplicationStatusTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): REPLICATION_STATUS = "ReplicationStatus" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -206,14 +205,14 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -222,7 +221,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -230,7 +229,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -238,7 +237,7 @@ class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E PREMIUM_LRS = "Premium_LRS" STANDARD_ZRS = "Standard_ZRS" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -246,7 +245,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. """ @@ -256,7 +255,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_SSD_LRS = "StandardSSD_LRS" ULTRA_SSD_LRS = "UltraSSD_LRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -268,7 +267,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -276,7 +275,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -285,7 +284,7 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for virtual machines in a low priority scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview """ @@ -293,7 +292,7 @@ class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for the virtual machines in the scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview """ @@ -301,14 +300,14 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E REGULAR = "Regular" LOW = "Low" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. For more information about virtual machine sizes, see `Sizes for virtual machines `_. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/_models_py3.py index 7d0e026f444f..b419774ecc77 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -83,7 +85,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2018_06_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -104,7 +106,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -117,7 +119,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2018_06_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -185,8 +187,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -396,11 +398,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -458,7 +460,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -540,11 +542,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -729,8 +731,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore". :vartype create_option: str or ~azure.mgmt.compute.v2018_06_01.models.DiskCreateOption :ivar storage_account_id: If createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in a @@ -761,16 +763,16 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, **kwargs ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore". + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore". :paramtype create_option: str or ~azure.mgmt.compute.v2018_06_01.models.DiskCreateOption :keyword storage_account_id: If createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in @@ -813,8 +815,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -825,7 +826,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2018_06_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -856,14 +857,14 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ @@ -882,8 +883,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -894,7 +894,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2018_06_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -960,7 +960,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -977,8 +977,8 @@ def __init__( class DiffDiskSettings(msrest.serialization.Model): """Describes the parameters of ephemeral disk settings that can be specified for operating system disk. :code:`
`:code:`
` NOTE: The ephemeral disk settings can only be specified for managed disk. - :ivar option: Specifies the ephemeral disk settings for operating system disk. Possible values - include: "Local". + :ivar option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :vartype option: str or ~azure.mgmt.compute.v2018_06_01.models.DiffDiskOptions """ @@ -989,12 +989,12 @@ class DiffDiskSettings(msrest.serialization.Model): def __init__( self, *, - option: Optional[Union[str, "DiffDiskOptions"]] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, **kwargs ): """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. Possible - values include: "Local". + :keyword option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :paramtype option: str or ~azure.mgmt.compute.v2018_06_01.models.DiffDiskOptions """ super(DiffDiskSettings, self).__init__(**kwargs) @@ -1052,7 +1052,7 @@ class Disk(Resource): :vartype zones: list[str] :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1112,12 +1112,12 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - creation_data: Optional["CreationData"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -1132,7 +1132,7 @@ def __init__( :paramtype sku: ~azure.mgmt.compute.v2018_06_01.models.DiskSku :keyword zones: The Logical zone list for Disk. :paramtype zones: list[str] - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1190,8 +1190,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -1233,8 +1233,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1277,7 +1277,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -1298,8 +1298,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS". :vartype name: str or ~azure.mgmt.compute.v2018_06_01.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -1317,11 +1317,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype name: str or ~azure.mgmt.compute.v2018_06_01.models.DiskStorageAccountTypes """ @@ -1338,7 +1338,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :vartype sku: ~azure.mgmt.compute.v2018_06_01.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -1370,10 +1370,10 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -1384,7 +1384,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :paramtype sku: ~azure.mgmt.compute.v2018_06_01.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -1435,8 +1435,8 @@ def __init__( self, *, enabled: Optional[bool] = None, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -1479,8 +1479,8 @@ class Gallery(Resource): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2018_06_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2018_06_01.models.GalleryPropertiesProvisioningState """ @@ -1510,7 +1510,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, **kwargs ): """ @@ -1554,8 +1554,8 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): def __init__( self, *, - source: "GalleryArtifactSource", - target_regions: Optional[List["TargetRegion"]] = None, + source: "_models.GalleryArtifactSource", + target_regions: Optional[List["_models.TargetRegion"]] = None, **kwargs ): """ @@ -1591,7 +1591,7 @@ class GalleryArtifactSource(msrest.serialization.Model): def __init__( self, *, - managed_image: "ManagedArtifact", + managed_image: "_models.ManagedArtifact", **kwargs ): """ @@ -1610,7 +1610,7 @@ class GalleryDiskImage(msrest.serialization.Model): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2018_06_01.models.HostCaching """ @@ -1643,7 +1643,7 @@ class GalleryDataDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2018_06_01.models.HostCaching :ivar lun: This property specifies the logical unit number of the data disk. This value is used to identify data disks within the Virtual Machine and therefore must be unique for each data @@ -1729,10 +1729,10 @@ class GalleryImage(Resource): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes - :ivar os_state: The allowed values for OS State are 'Generalized'. Possible values include: + :ivar os_state: The allowed values for OS State are 'Generalized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemStateTypes :ivar end_of_life_date: The end of life date of the gallery Image Definition. This property can @@ -1748,8 +1748,8 @@ class GalleryImage(Resource): :ivar purchase_plan: Describes the gallery Image Definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2018_06_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2018_06_01.models.GalleryImagePropertiesProvisioningState """ @@ -1791,13 +1791,13 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, **kwargs ): """ @@ -1816,10 +1816,10 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes - :keyword os_state: The allowed values for OS State are 'Generalized'. Possible values include: + :keyword os_state: The allowed values for OS State are 'Generalized'. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemStateTypes :keyword end_of_life_date: The end of life date of the gallery Image Definition. This property @@ -1922,7 +1922,7 @@ class GalleryImageList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImage"], + value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs ): @@ -1958,8 +1958,8 @@ class GalleryImageVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery Image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2018_06_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2018_06_01.models.GalleryImageVersionPropertiesProvisioningState :ivar storage_profile: This is the storage profile of a gallery Image Version. @@ -1996,7 +1996,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, **kwargs ): """ @@ -2039,7 +2039,7 @@ class GalleryImageVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImageVersion"], + value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs ): @@ -2098,8 +2098,8 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) def __init__( self, *, - source: "GalleryArtifactSource", - target_regions: Optional[List["TargetRegion"]] = None, + source: "_models.GalleryArtifactSource", + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, @@ -2186,7 +2186,7 @@ class GalleryList(msrest.serialization.Model): def __init__( self, *, - value: List["Gallery"], + value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs ): @@ -2210,7 +2210,7 @@ class GalleryOSDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2018_06_01.models.HostCaching """ @@ -2238,7 +2238,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read". + :ivar access: Required. Known values are: "None", "Read". :vartype access: str or ~azure.mgmt.compute.v2018_06_01.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -2257,12 +2257,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read". + :keyword access: Required. Known values are: "None", "Read". :paramtype access: str or ~azure.mgmt.compute.v2018_06_01.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -2285,8 +2285,8 @@ class HardwareProfile(msrest.serialization.Model): :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -2331,7 +2331,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -2345,8 +2345,8 @@ def __init__( :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -2436,8 +2436,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, **kwargs ): """ @@ -2474,16 +2474,15 @@ class ImageDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2018_06_01.models.StorageAccountTypes """ @@ -2506,12 +2505,12 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ @@ -2528,16 +2527,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2018_06_01.models.StorageAccountTypes """ @@ -2617,7 +2615,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -2640,10 +2638,10 @@ class ImageOSDisk(msrest.serialization.Model): :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemStateTypes :ivar snapshot: The snapshot. :vartype snapshot: ~azure.mgmt.compute.v2018_06_01.models.SubResource @@ -2654,16 +2652,15 @@ class ImageOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. - UltraSSD_LRS cannot be used with OS Disk. Possible values include: "Standard_LRS", - "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", + "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2018_06_01.models.StorageAccountTypes """ @@ -2687,24 +2684,23 @@ class ImageOSDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemStateTypes :keyword snapshot: The snapshot. :paramtype snapshot: ~azure.mgmt.compute.v2018_06_01.models.SubResource @@ -2715,16 +2711,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. - UltraSSD_LRS cannot be used with OS Disk. Possible values include: "Standard_LRS", - "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", + "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2018_06_01.models.StorageAccountTypes """ @@ -2892,8 +2887,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -2948,8 +2943,8 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, **kwargs ): """ @@ -3003,7 +2998,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2018_06_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -3025,7 +3020,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -3034,7 +3029,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2018_06_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -3075,7 +3070,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -3114,7 +3109,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -3154,7 +3149,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -3193,7 +3188,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -3232,7 +3227,7 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, provision_vm_agent: Optional[bool] = None, **kwargs ): @@ -3278,7 +3273,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -3432,8 +3427,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2018_06_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -3458,7 +3453,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -3474,8 +3469,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2018_06_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -3528,8 +3523,8 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2018_06_01.models.StorageAccountTypes """ @@ -3543,15 +3538,15 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2018_06_01.models.StorageAccountTypes """ @@ -3608,7 +3603,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -3628,8 +3623,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -3645,8 +3640,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -3660,7 +3654,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2018_06_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -3691,24 +3685,24 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -3724,8 +3718,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -3739,7 +3732,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2018_06_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -3767,8 +3760,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes """ @@ -3783,12 +3776,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -3878,9 +3871,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, **kwargs ): @@ -4027,7 +4020,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2018_06_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -4068,7 +4061,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, **kwargs ): """ @@ -4079,7 +4072,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2018_06_01.models.ProximityPlacementGroupType """ @@ -4113,7 +4106,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -4218,8 +4211,8 @@ class RecommendedMachineConfiguration(msrest.serialization.Model): def __init__( self, *, - v_cp_us: Optional["ResourceRange"] = None, - memory: Optional["ResourceRange"] = None, + v_cp_us: Optional["_models.ResourceRange"] = None, + memory: Optional["_models.ResourceRange"] = None, **kwargs ): """ @@ -4273,7 +4266,7 @@ class RegionalReplicationStatus(msrest.serialization.Model): :ivar region: The region to which the gallery Image Version is being replicated to. :vartype region: str - :ivar state: This is the regional replication state. Possible values include: "Unknown", + :ivar state: This is the regional replication state. Known values are: "Unknown", "Replicating", "Completed", "Failed". :vartype state: str or ~azure.mgmt.compute.v2018_06_01.models.ReplicationState :ivar details: The details of the replication status. @@ -4315,8 +4308,7 @@ class ReplicationStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Possible values include: "Unknown", "InProgress", "Completed", - "Failed". + replication status flags. Known values are: "Unknown", "InProgress", "Completed", "Failed". :vartype aggregated_state: str or ~azure.mgmt.compute.v2018_06_01.models.AggregatedReplicationState :ivar summary: This is a summary of replication status for each region. @@ -4363,7 +4355,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_resource_name: Group query result by Resource Name. :vartype group_by_resource_name: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2018_06_01.models.IntervalInMins """ @@ -4390,7 +4382,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -4411,7 +4403,7 @@ def __init__( :keyword group_by_resource_name: Group query result by Resource Name. :paramtype group_by_resource_name: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2018_06_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, **kwargs) @@ -4612,13 +4604,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2018_06_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2018_06_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -4731,8 +4723,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -4761,7 +4752,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -4771,8 +4762,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -4796,8 +4786,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -4833,11 +4822,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -4845,8 +4834,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -4892,7 +4880,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -4973,7 +4961,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -5056,7 +5044,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -5133,7 +5121,7 @@ class Snapshot(Resource): :vartype sku: ~azure.mgmt.compute.v2018_06_01.models.SnapshotSku :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -5180,11 +5168,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ @@ -5194,7 +5182,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2018_06_01.models.SnapshotSku - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -5242,7 +5230,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -5263,8 +5251,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2018_06_01.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -5282,12 +5269,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2018_06_01.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -5302,7 +5288,7 @@ class SnapshotUpdate(msrest.serialization.Model): :vartype tags: dict[str, str] :ivar sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :vartype sku: ~azure.mgmt.compute.v2018_06_01.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -5325,10 +5311,10 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings: Optional["EncryptionSettings"] = None, + encryption_settings: Optional["_models.EncryptionSettings"] = None, **kwargs ): """ @@ -5336,7 +5322,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2018_06_01.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -5393,7 +5379,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -5475,9 +5461,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -5683,7 +5669,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2018_06_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2018_06_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2018_06_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -5730,7 +5716,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2018_06_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -5770,8 +5756,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2018_06_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -5794,10 +5780,10 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, automatic_os_upgrade: Optional[bool] = None, - auto_os_upgrade_policy: Optional["AutoOSUpgradePolicy"] = None, + auto_os_upgrade_policy: Optional["_models.AutoOSUpgradePolicy"] = None, **kwargs ): """ @@ -5805,8 +5791,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2018_06_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -5863,7 +5849,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -6017,8 +6003,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -6175,17 +6161,17 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -6285,8 +6271,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -6482,7 +6468,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -6547,7 +6533,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -6684,8 +6670,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -6722,7 +6708,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -6854,8 +6840,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2018_06_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -6879,15 +6865,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2018_06_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -7004,9 +6990,9 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, **kwargs ): """ @@ -7092,12 +7078,12 @@ def __init__( os_name: Optional[str] = None, os_version: Optional[str] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -7170,7 +7156,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -7303,17 +7289,17 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -7385,14 +7371,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2018_06_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -7422,12 +7407,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -7440,14 +7425,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2018_06_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -7596,7 +7580,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -7627,7 +7611,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs ): """ @@ -7653,7 +7637,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2018_06_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine @@ -7678,15 +7662,15 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2018_06_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual @@ -7764,7 +7748,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -7824,7 +7808,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2018_06_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -7868,14 +7852,14 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -7893,7 +7877,7 @@ def __init__( ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2018_06_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -7984,7 +7968,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -8025,7 +8009,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -8065,7 +8049,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -8105,7 +8089,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -8126,8 +8110,8 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can - only be used with data disks, it cannot be used with OS Disk. Possible values include: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", + "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2018_06_01.models.StorageAccountTypes """ @@ -8139,13 +8123,13 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS - can only be used with data disks, it cannot be used with OS Disk. Possible values include: + can only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2018_06_01.models.StorageAccountTypes @@ -8203,9 +8187,9 @@ def __init__( id: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -8286,8 +8270,8 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -8314,8 +8298,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -8324,8 +8307,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2018_06_01.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -8336,8 +8319,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2018_06_01.models.VirtualHardDisk @@ -8369,16 +8352,16 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -8387,8 +8370,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -8397,8 +8379,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2018_06_01.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -8410,7 +8392,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_06_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2018_06_01.models.VirtualHardDisk @@ -8509,9 +8491,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -8615,9 +8597,9 @@ def __init__( *, name: str, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -8787,8 +8769,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -8850,9 +8831,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -8924,14 +8905,14 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, single_placement_group: Optional[bool] = None, - proximity_placement_group: Optional["SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -8989,7 +8970,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2018_06_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -9023,14 +9004,14 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -9048,7 +9029,7 @@ def __init__( ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2018_06_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -9119,9 +9100,9 @@ def __init__( name: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -9171,7 +9152,7 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, **kwargs ): """ @@ -9186,7 +9167,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -9218,16 +9199,16 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_06_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -9279,9 +9260,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -9324,7 +9305,7 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, **kwargs ): """ @@ -9363,9 +9344,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -9416,11 +9397,11 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, **kwargs ): @@ -9574,14 +9555,14 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -9805,12 +9786,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -9880,7 +9861,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -9930,12 +9911,12 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low". :vartype priority: str or ~azure.mgmt.compute.v2018_06_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for virtual machines in a low priority - scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values - include: "Deallocate", "Delete". + scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: + "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineEvictionPolicyTypes """ @@ -9955,15 +9936,15 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, **kwargs ): """ @@ -9999,12 +9980,12 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low". :paramtype priority: str or ~azure.mgmt.compute.v2018_06_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for virtual machines in a low priority - scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values - include: "Deallocate", "Delete". + scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: + "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineEvictionPolicyTypes """ @@ -10098,7 +10079,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -10234,17 +10215,17 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -10355,8 +10336,8 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -10401,7 +10382,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -10416,8 +10397,8 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :vartype protocol: str or ~azure.mgmt.compute.v2018_06_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault @@ -10437,14 +10418,14 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2018_06_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/__init__.py index ae7010225ed5..7a15b1929df9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/__init__.py @@ -28,6 +28,9 @@ from ._disks_operations import DisksOperations from ._snapshots_operations import SnapshotsOperations +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', 'AvailabilitySetsOperations', @@ -51,3 +54,5 @@ 'DisksOperations', 'SnapshotsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_availability_sets_operations.py index b753db0aa095..1af379adefc3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +190,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -199,20 +205,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -235,18 +242,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -257,9 +262,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -271,51 +279,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -329,14 +333,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2018_06_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -348,11 +355,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -378,9 +387,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -394,14 +403,17 @@ def update( :rtype: ~azure.mgmt.compute.v2018_06_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -413,11 +425,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,13 +470,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -471,11 +488,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -498,7 +517,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -510,13 +529,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -525,11 +547,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -555,7 +579,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -568,13 +592,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -583,9 +610,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +623,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -634,7 +665,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -646,13 +677,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +695,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -672,9 +708,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -713,7 +751,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -728,13 +766,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -756,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_disks_operations.py index fa3f3c4bbadb..c4fe8a5910cf 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_galleries_operations.py index 5ad8fd11b171..1bbbd65c439a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.Gallery] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,9 +80,12 @@ def build_get_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -93,18 +97,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -115,9 +117,12 @@ def build_delete_request_initial( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -129,18 +134,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -150,9 +153,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries") # pylint: disable=line-too-long path_format_arguments = { @@ -163,18 +169,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -183,9 +187,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") path_format_arguments = { @@ -195,58 +202,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleriesOperations(object): - """GalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -258,11 +264,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -295,9 +303,9 @@ def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -319,37 +327,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -368,7 +386,7 @@ def get( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -380,13 +398,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -395,11 +416,13 @@ def get( gallery_name=gallery_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -426,13 +449,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -441,11 +467,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -487,20 +515,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -510,8 +543,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -529,7 +568,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -539,13 +578,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +596,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -565,9 +609,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -604,7 +650,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -612,13 +658,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -626,9 +675,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -636,9 +687,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_gallery_image_versions_operations.py index 89ea53809f99..f034235a22ad 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -87,9 +88,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -103,20 +107,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -129,9 +131,12 @@ def build_delete_request_initial( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -145,18 +150,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -168,9 +171,12 @@ def build_list_by_gallery_image_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -183,42 +189,38 @@ def build_list_by_gallery_image_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImageVersionsOperations(object): - """GalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -226,17 +228,20 @@ def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -250,11 +255,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -289,9 +296,9 @@ def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Create or update a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -324,17 +331,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -343,20 +353,27 @@ def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -378,7 +395,7 @@ def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -398,13 +415,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -416,11 +436,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -449,13 +471,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -466,11 +491,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -520,22 +547,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -545,8 +577,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -566,7 +604,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageVersionList"]: + ) -> Iterable[_models.GalleryImageVersionList]: """List gallery Image Versions in a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -584,13 +622,16 @@ def list_by_gallery_image( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -601,9 +642,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -614,9 +657,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_gallery_images_operations.py index 924f5f7bea22..5e353fbcc6c7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImage] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,9 +83,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,18 +101,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -120,9 +122,12 @@ def build_delete_request_initial( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -157,9 +160,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images") # pylint: disable=line-too-long path_format_arguments = { @@ -171,59 +177,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImagesOperations(object): - """GalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -236,11 +241,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -274,9 +281,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Create or update a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -303,17 +310,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -321,20 +331,27 @@ def begin_create_or_update( 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('GalleryImage', 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( @@ -354,7 +371,7 @@ def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -369,13 +386,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -385,11 +405,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -417,13 +439,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -433,11 +458,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -483,21 +510,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -507,8 +539,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -527,7 +565,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageList"]: + ) -> Iterable[_models.GalleryImageList]: """List gallery Image Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -540,13 +578,16 @@ def list_by_gallery( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -556,9 +597,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -568,9 +611,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_images_operations.py index 0a768f1e99b2..3f11b280bb71 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -155,9 +157,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +174,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -192,9 +195,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -205,18 +211,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +229,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -237,58 +244,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -300,11 +306,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -334,9 +342,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -357,37 +365,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -404,17 +422,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -426,11 +447,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -460,9 +483,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -483,37 +506,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -532,13 +565,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -547,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,20 +631,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -616,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -637,7 +686,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -651,13 +700,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -667,11 +719,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -707,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -722,9 +779,11 @@ def prepare_request(next_link=None): 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: @@ -733,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -772,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -781,13 +842,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -805,9 +871,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_log_analytics_operations.py index b07c4e01d46c..169cd6cfd514 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_operations.py index cc071fe501c6..138aa7d10d73 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_proximity_placement_groups_operations.py index 74c689442f1d..d8a85343619b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -185,9 +188,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -197,18 +203,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -218,9 +222,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -231,51 +238,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -289,14 +292,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2018_06_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -308,11 +314,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -342,9 +350,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -358,14 +366,17 @@ def update( :rtype: ~azure.mgmt.compute.v2018_06_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -377,11 +388,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -420,13 +433,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -435,11 +451,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -462,7 +480,7 @@ def get( resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -474,13 +492,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -489,11 +510,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -518,7 +541,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -528,13 +551,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -542,9 +568,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -552,9 +580,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -592,7 +622,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -604,13 +634,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -619,9 +652,11 @@ def prepare_request(next_link=None): 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: @@ -630,9 +665,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_snapshots_operations.py index b87a34df6284..5e843591a12d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_usage_operations.py index 7251a81a81d2..fe6bb6cdeec3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_extension_images_operations.py index 26c51b789f6b..90cac95b53f9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_extensions_operations.py index 8274a5098868..4aabaf1f354e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,8 +129,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -141,13 +144,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -161,9 +163,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -176,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -202,9 +205,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -216,61 +222,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -283,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -318,9 +325,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -347,17 +354,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -365,20 +375,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -396,17 +413,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -419,11 +439,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,9 +472,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -479,17 +501,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -497,20 +522,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -530,13 +562,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -546,11 +581,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,21 +632,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -619,8 +661,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -641,7 +689,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -657,13 +705,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -674,11 +725,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -706,7 +759,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -720,13 +773,16 @@ def list( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -736,11 +792,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_images_operations.py index c0e5f3969649..3b47f83e9c8d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_run_commands_operations.py index 544ce6d44e7f..8ee87e8431c3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_run_commands_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -44,18 +48,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -66,9 +68,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -80,49 +85,45 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -134,13 +135,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -149,9 +153,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -160,9 +166,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -201,7 +209,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -213,13 +221,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -228,11 +239,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_set_extensions_operations.py index 3fbe19d39143..d7b119a00852 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,8 +83,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -96,13 +98,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -116,9 +117,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +135,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -155,9 +157,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -169,59 +174,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -234,11 +238,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -269,9 +275,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -299,17 +305,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -317,20 +326,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -350,13 +366,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -366,11 +385,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -415,21 +436,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -439,8 +465,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -461,7 +493,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -477,13 +509,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -494,11 +529,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -525,7 +562,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -539,13 +576,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -555,9 +595,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_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,9 +609,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 6e237a0ee0a4..ba5017447e9d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,8 +34,9 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -46,13 +48,12 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -63,8 +64,9 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -76,13 +78,12 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -93,8 +94,9 @@ def build_start_extension_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -106,13 +108,12 @@ def build_start_extension_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -123,9 +124,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -137,42 +141,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -180,13 +180,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -195,11 +198,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,20 +246,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -264,8 +274,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -284,13 +300,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -299,11 +318,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,20 +368,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -370,8 +396,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -390,13 +422,16 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -405,11 +440,13 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -453,20 +490,25 @@ def begin_start_extension_upgrade( # pylint: disable=inconsistent-return-statem :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_extension_upgrade_initial( + raw_result = self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -476,8 +518,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -496,7 +544,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -508,13 +556,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2018_06_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -523,11 +574,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_set_vms_operations.py index 4e0c6a16b075..cfe432ad42e8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,13 +35,15 @@ def build_reimage_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -54,19 +56,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,8 +80,9 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -94,13 +95,12 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -112,8 +112,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -126,13 +127,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -143,14 +143,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -163,20 +166,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -190,8 +191,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -204,13 +206,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -222,9 +223,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -237,18 +241,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -260,9 +262,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -275,18 +280,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -301,9 +304,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -315,24 +321,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -344,8 +348,9 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -358,13 +363,12 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -376,8 +380,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -390,13 +395,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -408,8 +412,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -422,13 +427,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -440,8 +444,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -454,13 +459,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -472,8 +476,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -486,13 +491,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -503,14 +507,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -523,63 +530,62 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -595,11 +601,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -622,7 +630,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -649,17 +657,20 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -667,6 +678,8 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -676,8 +689,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -697,13 +716,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -713,11 +735,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -763,21 +787,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -787,8 +816,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -808,13 +843,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -824,11 +862,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -875,21 +915,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -899,8 +944,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -918,17 +969,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -941,11 +995,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -976,9 +1032,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1004,17 +1060,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1022,20 +1081,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1055,13 +1121,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1071,11 +1140,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1120,21 +1191,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1144,8 +1220,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1165,7 +1247,7 @@ def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1179,13 +1261,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1195,11 +1280,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1227,7 +1314,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1241,13 +1328,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1257,11 +1347,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1291,7 +1383,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1315,13 +1407,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1334,9 +1429,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1349,9 +1446,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1391,13 +1490,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1407,11 +1509,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1458,21 +1562,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1482,8 +1591,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1503,13 +1618,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1519,11 +1637,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1568,21 +1688,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1592,8 +1717,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1613,13 +1744,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1629,11 +1763,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1678,21 +1814,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1702,8 +1843,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1723,13 +1870,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1739,11 +1889,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1789,21 +1941,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1813,8 +1970,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1834,13 +1997,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1850,11 +2016,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1899,21 +2067,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1923,8 +2096,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1942,18 +2121,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1966,11 +2148,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1999,11 +2183,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2014,7 +2198,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2018_06_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2030,16 +2214,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2047,20 +2234,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_sets_operations.py index 65532d55a824..f99374e53c52 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,18 +172,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -188,13 +191,15 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -206,19 +211,17 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -230,13 +233,15 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -248,19 +253,17 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -273,9 +276,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -287,18 +293,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -308,9 +312,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -321,18 +328,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -341,9 +346,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -353,18 +361,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -375,9 +381,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -389,18 +398,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -411,9 +418,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -425,18 +435,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -446,13 +454,15 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -464,19 +474,17 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -488,13 +496,15 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -506,19 +516,17 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -530,13 +538,15 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -548,19 +558,17 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -572,13 +580,15 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -590,19 +600,17 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -614,13 +622,15 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -632,19 +642,17 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -656,13 +664,15 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -674,19 +684,17 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -698,13 +706,15 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -716,19 +726,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -740,13 +748,15 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -758,19 +768,17 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -785,9 +793,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( platform_update_domain: int, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -799,59 +810,58 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -863,11 +873,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -897,9 +909,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -922,37 +934,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -969,17 +991,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -991,11 +1016,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1021,9 +1048,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1046,37 +1073,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1095,13 +1132,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1110,11 +1150,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1156,20 +1198,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1179,8 +1226,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1199,7 +1252,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1211,13 +1264,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1226,11 +1282,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1255,17 +1313,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1280,11 +1341,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1306,7 +1369,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1333,23 +1396,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1359,8 +1427,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1377,17 +1451,20 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1399,11 +1476,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1425,7 +1504,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -1449,23 +1528,28 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1475,8 +1559,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1495,7 +1585,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1507,13 +1597,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1522,11 +1615,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1552,7 +1647,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1564,13 +1659,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1579,9 +1677,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1590,9 +1690,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1629,7 +1731,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1641,13 +1743,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1655,9 +1760,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1665,9 +1772,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1706,7 +1815,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1721,13 +1830,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1737,9 +1849,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1749,9 +1863,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1790,7 +1906,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1804,13 +1920,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1820,9 +1939,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1832,9 +1953,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1871,17 +1994,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1896,11 +2022,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1922,7 +2050,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1949,23 +2077,28 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1975,8 +2108,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1993,17 +2132,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2018,11 +2160,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2044,7 +2188,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2069,23 +2213,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2095,8 +2244,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2113,17 +2268,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2138,11 +2296,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2164,7 +2324,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2189,23 +2349,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2215,8 +2380,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2233,17 +2404,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2258,11 +2432,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2284,7 +2460,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2310,23 +2486,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2336,8 +2517,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2354,17 +2541,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2379,11 +2569,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2405,7 +2597,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2433,23 +2625,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2459,8 +2656,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2477,17 +2680,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2499,11 +2705,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2525,7 +2733,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2549,23 +2757,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2575,8 +2788,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2593,17 +2812,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -2618,11 +2840,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2644,7 +2868,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -2670,23 +2894,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2696,8 +2925,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2714,17 +2949,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2739,11 +2977,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2765,7 +3005,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2791,23 +3031,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2817,8 +3062,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2838,7 +3089,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2854,13 +3105,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2018_06_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2870,11 +3124,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_sizes_operations.py index 764c956d710c..0d6a6436cd87 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -99,13 +99,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machines_operations.py index af466f777ccb..0eb64e0239ab 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_06_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -201,8 +205,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -214,13 +219,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -233,9 +237,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -247,20 +254,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -271,9 +276,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -285,18 +293,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -307,8 +313,9 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -320,13 +327,12 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -337,8 +343,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -350,13 +357,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -367,8 +373,9 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -380,13 +387,12 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -396,9 +402,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -409,18 +418,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -429,9 +436,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -441,18 +451,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -463,9 +471,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -477,18 +488,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -499,8 +508,9 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -512,13 +522,12 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -529,8 +538,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -542,13 +552,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -559,8 +568,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -572,13 +582,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -589,8 +598,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -602,13 +612,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -618,13 +627,15 @@ def build_reimage_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -636,19 +647,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -661,8 +670,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -674,13 +684,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -690,14 +699,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -709,53 +721,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2018_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.compute.v2018_06_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -767,13 +775,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -782,9 +793,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -793,9 +806,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -832,17 +847,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -854,11 +872,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -886,9 +906,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -912,37 +932,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -959,17 +989,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -981,11 +1014,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1015,9 +1050,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1039,37 +1074,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1086,17 +1131,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1108,11 +1156,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1142,9 +1192,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1166,37 +1216,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1215,13 +1275,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1230,11 +1293,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1276,20 +1341,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1299,8 +1369,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1320,28 +1396,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1351,11 +1430,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1382,7 +1463,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1394,13 +1475,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2018_06_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1409,11 +1493,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1440,13 +1526,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1455,11 +1544,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1502,20 +1593,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1525,8 +1621,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1545,13 +1647,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -1560,11 +1665,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1607,20 +1714,25 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1630,8 +1742,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1662,13 +1780,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1677,11 +1798,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1703,7 +1826,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1716,13 +1839,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1731,9 +1857,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1742,9 +1870,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1781,7 +1911,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1792,13 +1922,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1806,9 +1939,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1816,9 +1951,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1857,7 +1994,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1872,13 +2009,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_06_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1888,9 +2028,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1900,9 +2042,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1941,13 +2085,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1956,11 +2103,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2003,20 +2152,25 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2026,8 +2180,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2046,13 +2206,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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', "2018-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2061,11 +2224,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2107,20 +2272,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2130,8 +2300,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2150,13 +2326,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2165,11 +2344,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2211,20 +2392,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2234,8 +2420,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2254,13 +2446,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2269,11 +2464,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2315,20 +2512,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2338,8 +2540,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2356,17 +2564,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -2381,11 +2592,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2407,7 +2620,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -2431,23 +2644,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -2457,8 +2675,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2477,13 +2701,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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 {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2492,11 +2719,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2538,20 +2767,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2561,8 +2795,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2579,18 +2819,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2602,11 +2845,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2634,11 +2879,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2647,7 +2892,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2018_06_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2663,36 +2908,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_06_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/__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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/_compute_management_client.py index 9cbcc322a437..ab7f4468efd6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/_compute_management_client.py @@ -57,8 +57,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/_compute_management_client.py index d2a9bc767bd0..eb5ddb72139f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/_compute_management_client.py @@ -57,8 +57,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/__init__.py index 65a114a2a1fb..ab61712083ae 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/__init__.py @@ -9,7 +9,12 @@ from ._disks_operations import DisksOperations from ._snapshots_operations import SnapshotsOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/_disks_operations.py index a3a24661afd6..188890de8e5c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2018_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_09_30.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_09_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_09_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_09_30.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_09_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_09_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_09_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/_snapshots_operations.py index 8be3218d5075..e170a2e7f495 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2018_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_09_30.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_09_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_09_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_09_30.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_09_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_09_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_09_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/__init__.py index 74ffa823329b..f6043d7985ff 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/__init__.py @@ -35,7 +35,9 @@ OperatingSystemTypes, SnapshotStorageAccountTypes, ) - +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__ = [ 'AccessUri', 'CreationData', @@ -63,3 +65,5 @@ 'OperatingSystemTypes', 'SnapshotStorageAccountTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/_compute_management_client_enums.py index 0ed72e39ba56..fa1018bb27ea 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/_compute_management_client_enums.py @@ -7,17 +7,16 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" WRITE = "Write" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -29,7 +28,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESTORE = "Restore" UPLOAD = "Upload" -class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the disk. """ @@ -40,7 +39,7 @@ class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READY_TO_UPLOAD = "ReadyToUpload" ACTIVE_UPLOAD = "ActiveUpload" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -49,21 +48,21 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) STANDARD_SSD_LRS = "StandardSSD_LRS" ULTRA_SSD_LRS = "UltraSSD_LRS" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/_models_py3.py index 0065c95c0548..78a98c250fd3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -45,8 +47,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :vartype create_option: str or ~azure.mgmt.compute.v2018_09_30.models.DiskCreateOption :ivar storage_account_id: If createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in a @@ -77,16 +79,16 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, **kwargs ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :paramtype create_option: str or ~azure.mgmt.compute.v2018_09_30.models.DiskCreateOption :keyword storage_account_id: If createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in @@ -190,10 +192,10 @@ class Disk(Resource): :vartype zones: list[str] :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_09_30.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2018_09_30.models.HyperVGeneration :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -216,7 +218,7 @@ class Disk(Resource): disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. :vartype disk_m_bps_read_write: int - :ivar disk_state: The state of the disk. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", "Reserved", "ActiveSAS", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2018_09_30.models.DiskState """ @@ -258,13 +260,13 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - creation_data: Optional["CreationData"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -279,10 +281,10 @@ def __init__( :paramtype sku: ~azure.mgmt.compute.v2018_09_30.models.DiskSku :keyword zones: The Logical zone list for Disk. :paramtype zones: list[str] - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_09_30.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2018_09_30.models.HyperVGeneration :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -344,7 +346,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -365,8 +367,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS". :vartype name: str or ~azure.mgmt.compute.v2018_09_30.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -384,11 +386,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype name: str or ~azure.mgmt.compute.v2018_09_30.models.DiskStorageAccountTypes """ @@ -405,7 +407,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :vartype sku: ~azure.mgmt.compute.v2018_09_30.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_09_30.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -439,10 +441,10 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -453,7 +455,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :paramtype sku: ~azure.mgmt.compute.v2018_09_30.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_09_30.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -510,7 +512,7 @@ def __init__( self, *, enabled: bool, - encryption_settings: Optional[List["EncryptionSettingsElement"]] = None, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, **kwargs ): """ @@ -546,8 +548,8 @@ class EncryptionSettingsElement(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -568,7 +570,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read", "Write". + :ivar access: Required. Known values are: "None", "Read", "Write". :vartype access: str or ~azure.mgmt.compute.v2018_09_30.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -587,12 +589,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read", "Write". + :keyword access: Required. Known values are: "None", "Read", "Write". :paramtype access: str or ~azure.mgmt.compute.v2018_09_30.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -668,7 +670,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -707,7 +709,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -745,10 +747,10 @@ class Snapshot(Resource): :vartype sku: ~azure.mgmt.compute.v2018_09_30.models.SnapshotSku :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_09_30.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2018_09_30.models.HyperVGeneration :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -798,12 +800,12 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, **kwargs ): """ @@ -813,10 +815,10 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2018_09_30.models.SnapshotSku - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_09_30.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2018_09_30.models.HyperVGeneration :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -867,7 +869,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -888,8 +890,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2018_09_30.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -907,12 +908,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2018_09_30.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -927,7 +927,7 @@ class SnapshotUpdate(msrest.serialization.Model): :vartype tags: dict[str, str] :ivar sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :vartype sku: ~azure.mgmt.compute.v2018_09_30.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_09_30.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with @@ -952,10 +952,10 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, **kwargs ): """ @@ -963,7 +963,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2018_09_30.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_09_30.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/__init__.py index 65a114a2a1fb..ab61712083ae 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/__init__.py @@ -9,7 +9,12 @@ from ._disks_operations import DisksOperations from ._snapshots_operations import SnapshotsOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/_disks_operations.py index 39fa2f95180c..3c7d1861cdb8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_09_30.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_09_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_09_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_09_30.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_09_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_09_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_09_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2018-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/_snapshots_operations.py index faa8c18d56fc..ed1c0d57d832 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_09_30/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2018_09_30.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_09_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_09_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_09_30.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_09_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_09_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_09_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2018-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/_compute_management_client.py index 0114600695eb..fad105eea729 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/_compute_management_client.py @@ -98,22 +98,54 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/_compute_management_client.py index c0eff11afec0..f5c3c693ab5f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/_compute_management_client.py @@ -99,22 +99,54 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/__init__.py index d803388388c3..9d534c5afa2f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/__init__.py @@ -23,6 +23,9 @@ from ._log_analytics_operations import LogAnalyticsOperations from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations +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', 'AvailabilitySetsOperations', @@ -41,3 +44,5 @@ 'LogAnalyticsOperations', 'VirtualMachineRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_availability_sets_operations.py index 71272f2f5ed7..ce86e22d20f6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2018_10_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2018_10_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_images_operations.py index 00a16ba8ebeb..55cc1f7024ca 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_log_analytics_operations.py index 3c322cbb9b58..c54d3123c871 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_operations.py index e877dee70e26..4ddefdc0cff7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_proximity_placement_groups_operations.py index 8a3f5e06c396..635cd127c3f7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2018_10_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2018_10_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -239,7 +253,7 @@ async def get( resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -251,13 +265,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -266,11 +283,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -295,7 +314,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -319,9 +341,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -329,9 +353,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -369,7 +395,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -381,13 +407,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -396,9 +425,11 @@ def prepare_request(next_link=None): 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: @@ -407,9 +438,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_usage_operations.py index 679246a4d157..8d7bbcb9cf9a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_extension_images_operations.py index 65d03af2fa16..fb397f775c97 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_extensions_operations.py index e4d90aaf7f80..9a8d8f00f0be 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_images_operations.py index f7eb5a1ac550..c92c92ef482a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_run_commands_operations.py index 0c0c6036b2a8..4c8369befb2a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -15,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 @@ -24,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,7 +135,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -141,13 +147,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -156,11 +165,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index 164d59429d0c..7e8f0459141f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -191,13 +205,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -207,11 +224,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -256,21 +275,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -280,8 +304,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -302,7 +332,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -318,13 +348,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -335,11 +368,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,7 +401,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -380,13 +415,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -396,9 +434,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -408,9 +448,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index ef6b21d7d827..563b51fce067 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,13 +292,16 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu vm_scale_set_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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -276,11 +310,13 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,20 +360,25 @@ async def begin_start_extension_upgrade( # pylint: disable=inconsistent-return- :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._start_extension_upgrade_initial( + raw_result = await self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -347,8 +388,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -367,7 +414,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -379,13 +426,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2018_10_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -394,11 +444,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index 59f6916188b3..29ab28abb362 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -78,11 +80,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -132,17 +136,20 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -150,6 +157,8 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,13 +195,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -196,11 +214,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,21 +266,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -270,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -291,13 +322,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -307,11 +341,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,21 +394,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -382,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -401,17 +448,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -424,11 +474,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,9 +511,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -487,17 +539,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -505,20 +560,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -538,13 +600,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -554,11 +619,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -603,21 +670,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -627,8 +699,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -648,7 +726,7 @@ async def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -662,13 +740,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -678,11 +759,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -710,7 +793,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -724,13 +807,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -740,11 +826,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -774,7 +862,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -798,13 +886,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -817,9 +908,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -832,9 +925,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -874,13 +969,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -890,11 +988,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -941,21 +1041,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -965,8 +1070,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -986,13 +1097,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1002,11 +1116,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1051,21 +1167,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1075,8 +1196,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1096,13 +1223,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1112,11 +1242,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1161,21 +1293,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1185,8 +1322,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1206,13 +1349,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1222,11 +1368,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1272,21 +1420,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1296,8 +1449,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1317,13 +1476,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1333,11 +1495,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1382,21 +1546,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1406,8 +1575,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1425,18 +1600,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1449,11 +1627,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1482,11 +1662,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1497,7 +1677,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2018_10_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1514,16 +1694,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1531,20 +1714,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_sets_operations.py index 6d1355e6c0f3..715d89e8ece2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -231,9 +250,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -409,7 +454,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -421,13 +466,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -436,11 +484,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -465,17 +515,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -490,11 +543,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -516,7 +571,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -543,23 +598,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -569,8 +629,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -587,17 +653,20 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -609,11 +678,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,7 +706,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -659,23 +730,28 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +761,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +787,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -717,13 +799,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -732,11 +817,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -762,7 +849,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -774,13 +861,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -789,9 +879,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -800,9 +892,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -839,7 +933,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -851,13 +945,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -865,9 +962,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -875,9 +974,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +1017,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -931,13 +1032,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -947,9 +1051,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -959,9 +1065,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1000,7 +1108,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1014,13 +1122,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1030,9 +1141,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1042,9 +1155,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1081,17 +1196,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1106,11 +1224,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1132,7 +1252,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1159,23 +1279,28 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1185,8 +1310,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1203,17 +1334,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1228,11 +1362,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1254,7 +1390,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1279,23 +1415,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1305,8 +1446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1323,17 +1470,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1348,11 +1498,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1374,7 +1526,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1399,23 +1551,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1425,8 +1582,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1443,17 +1606,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1468,11 +1634,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1494,7 +1662,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1520,23 +1688,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1546,8 +1719,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1564,17 +1743,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1589,11 +1771,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1615,7 +1799,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1643,23 +1827,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1669,8 +1858,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1687,17 +1882,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1709,11 +1907,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1735,7 +1935,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1759,23 +1959,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1785,8 +1990,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1803,17 +2014,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -1828,11 +2042,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1854,7 +2070,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -1880,23 +2096,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1906,8 +2127,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1924,17 +2151,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1949,11 +2179,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1975,7 +2207,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2001,23 +2233,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2027,8 +2264,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2048,7 +2291,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2064,13 +2307,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2018_10_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2080,11 +2326,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_sizes_operations.py index d187c913a14b..94b4f5229784 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machines_operations.py index 990085ac1ced..c5a7b49aab2f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2018_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.compute.v2018_10_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -337,37 +363,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -384,17 +420,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -406,11 +445,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -440,9 +481,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -465,37 +506,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -514,13 +565,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -529,11 +583,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -575,20 +631,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -598,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -619,28 +686,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -650,11 +720,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -681,7 +753,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -693,13 +765,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -708,11 +783,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -739,13 +816,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -754,11 +834,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -801,20 +883,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -824,8 +911,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -844,13 +937,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -859,11 +955,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -906,20 +1004,25 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -929,8 +1032,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -961,13 +1070,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -976,11 +1088,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1002,7 +1116,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1015,13 +1129,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1030,9 +1147,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1041,9 +1160,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1080,7 +1201,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1091,13 +1212,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1105,9 +1229,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1115,9 +1241,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1156,7 +1284,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1171,13 +1299,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1187,9 +1318,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1199,9 +1332,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1240,13 +1375,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1255,11 +1393,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1302,20 +1442,25 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1325,8 +1470,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1345,13 +1496,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1360,11 +1514,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1406,20 +1562,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1429,8 +1590,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1449,13 +1616,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1464,11 +1634,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1510,20 +1682,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1533,8 +1710,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1553,13 +1736,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1568,11 +1754,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1614,20 +1802,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1637,8 +1830,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1655,17 +1854,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -1680,11 +1882,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1706,7 +1910,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -1730,23 +1934,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -1756,8 +1965,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1776,13 +1991,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1791,11 +2009,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1837,20 +2057,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1860,8 +2085,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1878,18 +2109,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1901,11 +2135,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1933,11 +2169,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -1946,7 +2182,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2018_10_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1963,36 +2199,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2018_10_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/__init__.py index e492ba988299..b69688101587 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/__init__.py @@ -185,7 +185,9 @@ VirtualMachineScaleSetSkuScaleType, VirtualMachineSizeTypes, ) - +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__ = [ 'AdditionalCapabilities', 'AdditionalUnattendContent', @@ -363,3 +365,5 @@ 'VirtualMachineScaleSetSkuScaleType', 'VirtualMachineSizeTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/_compute_management_client_enums.py index bd23c32539f5..e115158b2159 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. """ @@ -19,7 +18,7 @@ class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CLASSIC = "Classic" ALIGNED = "Aligned" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -30,13 +29,13 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DiffDiskOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk option for operating system disk. """ LOCAL = "Local" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -49,7 +48,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -58,7 +57,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -67,7 +66,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -76,21 +75,21 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ GENERALIZED = "Generalized" SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -98,7 +97,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -107,7 +106,7 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -118,14 +117,14 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -134,7 +133,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -142,7 +141,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -150,7 +149,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. """ @@ -160,7 +159,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_SSD_LRS = "StandardSSD_LRS" ULTRA_SSD_LRS = "UltraSSD_LRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -172,7 +171,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -180,7 +179,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -189,7 +188,7 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for virtual machines in a low priority scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview """ @@ -197,7 +196,7 @@ class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for the virtual machines in the scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview """ @@ -205,14 +204,14 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E REGULAR = "Regular" LOW = "Low" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. For more information about virtual machine sizes, see `Sizes for virtual machines `_. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/_models_py3.py index 7dde2ae3f4cd..bcbef0393b84 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AdditionalCapabilities(msrest.serialization.Model): @@ -56,7 +58,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2018_10_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -77,7 +79,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -90,7 +92,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2018_10_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -158,8 +160,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -461,11 +463,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -523,7 +525,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -605,11 +607,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -809,8 +811,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -821,7 +822,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2018_10_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -852,14 +853,14 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ @@ -878,8 +879,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -890,7 +890,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2018_10_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -956,7 +956,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -973,8 +973,8 @@ def __init__( class DiffDiskSettings(msrest.serialization.Model): """Describes the parameters of ephemeral disk settings that can be specified for operating system disk. :code:`
`:code:`
` NOTE: The ephemeral disk settings can only be specified for managed disk. - :ivar option: Specifies the ephemeral disk settings for operating system disk. Possible values - include: "Local". + :ivar option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :vartype option: str or ~azure.mgmt.compute.v2018_10_01.models.DiffDiskOptions """ @@ -985,12 +985,12 @@ class DiffDiskSettings(msrest.serialization.Model): def __init__( self, *, - option: Optional[Union[str, "DiffDiskOptions"]] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, **kwargs ): """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. Possible - values include: "Local". + :keyword option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :paramtype option: str or ~azure.mgmt.compute.v2018_10_01.models.DiffDiskOptions """ super(DiffDiskSettings, self).__init__(**kwargs) @@ -1018,8 +1018,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -1061,8 +1061,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1094,8 +1094,8 @@ class HardwareProfile(msrest.serialization.Model): :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -1140,7 +1140,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -1154,8 +1154,8 @@ def __init__( :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -1245,8 +1245,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, **kwargs ): """ @@ -1283,16 +1283,15 @@ class ImageDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2018_10_01.models.StorageAccountTypes """ @@ -1315,12 +1314,12 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ @@ -1337,16 +1336,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2018_10_01.models.StorageAccountTypes """ @@ -1384,7 +1382,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -1407,10 +1405,10 @@ class ImageOSDisk(msrest.serialization.Model): :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemStateTypes :ivar snapshot: The snapshot. :vartype snapshot: ~azure.mgmt.compute.v2018_10_01.models.SubResource @@ -1421,16 +1419,15 @@ class ImageOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. - UltraSSD_LRS cannot be used with OS Disk. Possible values include: "Standard_LRS", - "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", + "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2018_10_01.models.StorageAccountTypes """ @@ -1454,24 +1451,23 @@ class ImageOSDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemStateTypes :keyword snapshot: The snapshot. :paramtype snapshot: ~azure.mgmt.compute.v2018_10_01.models.SubResource @@ -1482,16 +1478,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. - UltraSSD_LRS cannot be used with OS Disk. Possible values include: "Standard_LRS", - "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", + "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2018_10_01.models.StorageAccountTypes """ @@ -1620,8 +1615,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -1676,8 +1671,8 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, **kwargs ): """ @@ -1731,7 +1726,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2018_10_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -1753,7 +1748,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -1762,7 +1757,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2018_10_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -1804,7 +1799,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -1843,7 +1838,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -1882,7 +1877,7 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, provision_vm_agent: Optional[bool] = None, **kwargs ): @@ -1928,7 +1923,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -2082,8 +2077,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2018_10_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -2108,7 +2103,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -2124,8 +2119,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2018_10_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -2147,8 +2142,8 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2018_10_01.models.StorageAccountTypes """ @@ -2162,15 +2157,15 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2018_10_01.models.StorageAccountTypes """ @@ -2227,7 +2222,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -2247,8 +2242,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -2264,8 +2259,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -2279,7 +2273,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2018_10_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -2310,24 +2304,24 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -2343,8 +2337,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -2358,7 +2351,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2018_10_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -2386,8 +2379,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemTypes """ @@ -2402,12 +2395,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -2497,9 +2490,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, **kwargs ): @@ -2646,7 +2639,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2018_10_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -2687,7 +2680,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, **kwargs ): """ @@ -2698,7 +2691,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2018_10_01.models.ProximityPlacementGroupType """ @@ -2732,7 +2725,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -2872,7 +2865,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_resource_name: Group query result by Resource Name. :vartype group_by_resource_name: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2018_10_01.models.IntervalInMins """ @@ -2899,7 +2892,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -2920,7 +2913,7 @@ def __init__( :keyword group_by_resource_name: Group query result by Resource Name. :paramtype group_by_resource_name: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2018_10_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, **kwargs) @@ -3089,13 +3082,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2018_10_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2018_10_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -3208,8 +3201,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -3238,7 +3230,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -3248,8 +3240,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -3273,8 +3264,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -3310,11 +3300,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -3322,8 +3312,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -3369,7 +3358,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -3450,7 +3439,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -3533,7 +3522,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -3601,7 +3590,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -3683,9 +3672,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -3851,7 +3840,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2018_10_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2018_10_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2018_10_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -3898,7 +3887,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2018_10_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -3938,8 +3927,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2018_10_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -3959,9 +3948,9 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["AutomaticOSUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, + automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, **kwargs ): """ @@ -3969,8 +3958,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2018_10_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -4024,7 +4013,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -4178,8 +4167,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -4336,17 +4325,17 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -4446,8 +4435,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -4643,7 +4632,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -4708,7 +4697,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -4845,8 +4834,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -4883,7 +4872,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -5015,8 +5004,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2018_10_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -5040,15 +5029,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2018_10_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -5169,10 +5158,10 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["AutomaticOSUpgradeProperties"] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, + automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, **kwargs ): """ @@ -5263,12 +5252,12 @@ def __init__( os_name: Optional[str] = None, os_version: Optional[str] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -5341,7 +5330,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -5483,19 +5472,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -5576,14 +5565,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2018_10_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5613,12 +5601,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -5631,14 +5619,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2018_10_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5787,7 +5774,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -5818,7 +5805,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs ): """ @@ -5844,7 +5831,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2018_10_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine @@ -5869,15 +5856,15 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2018_10_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual @@ -5955,7 +5942,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -6015,7 +6002,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2018_10_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -6059,14 +6046,14 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -6084,7 +6071,7 @@ def __init__( ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2018_10_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -6175,7 +6162,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -6216,7 +6203,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -6256,7 +6243,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -6296,7 +6283,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -6317,8 +6304,8 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can - only be used with data disks, it cannot be used with OS Disk. Possible values include: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", + "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2018_10_01.models.StorageAccountTypes """ @@ -6330,13 +6317,13 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS - can only be used with data disks, it cannot be used with OS Disk. Possible values include: + can only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2018_10_01.models.StorageAccountTypes @@ -6394,9 +6381,9 @@ def __init__( id: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -6477,8 +6464,8 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -6505,8 +6492,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -6515,8 +6501,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2018_10_01.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -6527,8 +6513,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2018_10_01.models.VirtualHardDisk @@ -6560,16 +6546,16 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -6578,8 +6564,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -6588,8 +6573,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2018_10_01.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -6601,7 +6586,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2018_10_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2018_10_01.models.VirtualHardDisk @@ -6700,9 +6685,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -6806,9 +6791,9 @@ def __init__( *, name: str, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -6978,8 +6963,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -7041,9 +7025,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -7124,16 +7108,16 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, - proximity_placement_group: Optional["SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -7200,7 +7184,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2018_10_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -7234,14 +7218,14 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -7259,7 +7243,7 @@ def __init__( ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2018_10_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -7330,9 +7314,9 @@ def __init__( name: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -7382,7 +7366,7 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, **kwargs ): """ @@ -7397,7 +7381,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -7429,16 +7413,16 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2018_10_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -7490,9 +7474,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -7535,7 +7519,7 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, **kwargs ): """ @@ -7574,9 +7558,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -7627,11 +7611,11 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, **kwargs ): @@ -7785,14 +7769,14 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -8016,12 +8000,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -8091,7 +8075,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -8141,12 +8125,12 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low". :vartype priority: str or ~azure.mgmt.compute.v2018_10_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for virtual machines in a low priority - scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values - include: "Deallocate", "Delete". + scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: + "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineEvictionPolicyTypes """ @@ -8166,15 +8150,15 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, **kwargs ): """ @@ -8210,12 +8194,12 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low". :paramtype priority: str or ~azure.mgmt.compute.v2018_10_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for virtual machines in a low priority - scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values - include: "Deallocate", "Delete". + scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: + "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineEvictionPolicyTypes """ @@ -8309,7 +8293,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -8445,17 +8429,17 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -8567,8 +8551,8 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -8614,7 +8598,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -8629,8 +8613,8 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :vartype protocol: str or ~azure.mgmt.compute.v2018_10_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault @@ -8650,14 +8634,14 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2018_10_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/__init__.py index d803388388c3..9d534c5afa2f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/__init__.py @@ -23,6 +23,9 @@ from ._log_analytics_operations import LogAnalyticsOperations from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations +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', 'AvailabilitySetsOperations', @@ -41,3 +44,5 @@ 'LogAnalyticsOperations', 'VirtualMachineRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_availability_sets_operations.py index 86d53b4325d8..c4c9277d881c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +190,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -199,20 +205,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -235,18 +242,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -257,9 +262,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -271,51 +279,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -329,14 +333,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2018_10_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -348,11 +355,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -378,9 +387,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -394,14 +403,17 @@ def update( :rtype: ~azure.mgmt.compute.v2018_10_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -413,11 +425,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,13 +470,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -471,11 +488,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -498,7 +517,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -510,13 +529,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -525,11 +547,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -555,7 +579,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -568,13 +592,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -583,9 +610,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +623,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -634,7 +665,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -646,13 +677,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +695,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -672,9 +708,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -713,7 +751,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -728,13 +766,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -756,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_images_operations.py index b9fe0a6e9d44..74975e7268b7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -155,9 +157,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +174,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -192,9 +195,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -205,18 +211,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +229,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -237,58 +244,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -300,11 +306,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -334,9 +342,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -357,37 +365,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -404,17 +422,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -426,11 +447,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -460,9 +483,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -483,37 +506,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -532,13 +565,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -547,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,20 +631,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -616,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -637,7 +686,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -651,13 +700,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -667,11 +719,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -707,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -722,9 +779,11 @@ def prepare_request(next_link=None): 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: @@ -733,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -772,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -781,13 +842,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -805,9 +871,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_log_analytics_operations.py index 851de1f99971..402df6f8cc67 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_operations.py index c007aa746797..c2b00ba09a3b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_proximity_placement_groups_operations.py index 1ccc03da4c5f..ac6b920b181e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -185,9 +188,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -197,18 +203,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -218,9 +222,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -231,51 +238,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -289,14 +292,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2018_10_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -308,11 +314,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -342,9 +350,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -358,14 +366,17 @@ def update( :rtype: ~azure.mgmt.compute.v2018_10_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -377,11 +388,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -420,13 +433,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -435,11 +451,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -462,7 +480,7 @@ def get( resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -474,13 +492,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -489,11 +510,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -518,7 +541,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -528,13 +551,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -542,9 +568,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -552,9 +580,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -592,7 +622,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -604,13 +634,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -619,9 +652,11 @@ def prepare_request(next_link=None): 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: @@ -630,9 +665,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_usage_operations.py index 89c263c67042..17bd65b4e878 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_extension_images_operations.py index e4e18c3562cf..b1a26dad19f1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_extensions_operations.py index 516547e753c7..2d1b1fa15800 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,8 +129,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -141,13 +144,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -161,9 +163,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -176,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -202,9 +205,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -216,61 +222,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -283,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -318,9 +325,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -347,17 +354,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -365,20 +375,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -396,17 +413,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -419,11 +439,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,9 +472,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -479,17 +501,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -497,20 +522,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -530,13 +562,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -546,11 +581,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,21 +632,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -619,8 +661,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -641,7 +689,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -657,13 +705,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -674,11 +725,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -706,7 +759,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -720,13 +773,16 @@ def list( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -736,11 +792,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_images_operations.py index 1a32b671b2f4..f23762a18dd3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_run_commands_operations.py index cb542d164fc8..ee129afc041a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_run_commands_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -44,18 +48,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -66,9 +68,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -80,49 +85,45 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -134,13 +135,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -149,9 +153,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -160,9 +166,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -201,7 +209,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -213,13 +221,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -228,11 +239,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_set_extensions_operations.py index a34dcbc7d04c..d81b3f86e5e6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,8 +83,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -96,13 +98,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -116,9 +117,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +135,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -155,9 +157,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -169,59 +174,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -234,11 +238,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -269,9 +275,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -299,17 +305,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -317,20 +326,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -350,13 +366,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -366,11 +385,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -415,21 +436,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -439,8 +465,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -461,7 +493,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -477,13 +509,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -494,11 +529,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -525,7 +562,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -539,13 +576,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -555,9 +595,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_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,9 +609,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 1cec9e14cbbb..cd90d2997b19 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,8 +34,9 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -46,13 +48,12 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -63,8 +64,9 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -76,13 +78,12 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -93,8 +94,9 @@ def build_start_extension_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -106,13 +108,12 @@ def build_start_extension_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -123,9 +124,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -137,42 +141,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -180,13 +180,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -195,11 +198,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,20 +246,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -264,8 +274,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -284,13 +300,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -299,11 +318,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,20 +368,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -370,8 +396,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -390,13 +422,16 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -405,11 +440,13 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -453,20 +490,25 @@ def begin_start_extension_upgrade( # pylint: disable=inconsistent-return-statem :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._start_extension_upgrade_initial( + raw_result = self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -476,8 +518,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -496,7 +544,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -508,13 +556,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2018_10_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -523,11 +574,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_set_vms_operations.py index 2440bfb8b14d..eb05fcb2f03e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,13 +35,15 @@ def build_reimage_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -54,19 +56,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,8 +80,9 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -94,13 +95,12 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -112,8 +112,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -126,13 +127,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -143,14 +143,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -163,20 +166,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -190,8 +191,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -204,13 +206,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -222,9 +223,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -237,18 +241,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -260,9 +262,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -275,18 +280,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -301,9 +304,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -315,24 +321,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -344,8 +348,9 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -358,13 +363,12 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -376,8 +380,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -390,13 +395,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -408,8 +412,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -422,13 +427,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -440,8 +444,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -454,13 +459,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -472,8 +476,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -486,13 +491,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -503,14 +507,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -523,63 +530,62 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -595,11 +601,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -622,7 +630,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -649,17 +657,20 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -667,6 +678,8 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -676,8 +689,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -697,13 +716,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -713,11 +735,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -763,21 +787,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -787,8 +816,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -808,13 +843,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -824,11 +862,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -875,21 +915,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -899,8 +944,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -918,17 +969,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -941,11 +995,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -976,9 +1032,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1004,17 +1060,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1022,20 +1081,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1055,13 +1121,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1071,11 +1140,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1120,21 +1191,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1144,8 +1220,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1165,7 +1247,7 @@ def get( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1179,13 +1261,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1195,11 +1280,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1227,7 +1314,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1241,13 +1328,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1257,11 +1347,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1291,7 +1383,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1315,13 +1407,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1334,9 +1429,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1349,9 +1446,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1391,13 +1490,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1407,11 +1509,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1458,21 +1562,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1482,8 +1591,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1503,13 +1618,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1519,11 +1637,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1568,21 +1688,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1592,8 +1717,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1613,13 +1744,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1629,11 +1763,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1678,21 +1814,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1702,8 +1843,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1723,13 +1870,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1739,11 +1889,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1789,21 +1941,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1813,8 +1970,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1834,13 +1997,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1850,11 +2016,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1899,21 +2067,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1923,8 +2096,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1942,18 +2121,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1966,11 +2148,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1999,11 +2183,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2014,7 +2198,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2018_10_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2030,16 +2214,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2047,20 +2234,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_sets_operations.py index db1ff252e869..c30343e57576 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,18 +172,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -188,13 +191,15 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -206,19 +211,17 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -230,13 +233,15 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -248,19 +253,17 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -273,9 +276,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -287,18 +293,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -308,9 +312,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -321,18 +328,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -341,9 +346,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -353,18 +361,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -375,9 +381,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -389,18 +398,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -411,9 +418,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -425,18 +435,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -446,13 +454,15 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -464,19 +474,17 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -488,13 +496,15 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -506,19 +516,17 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -530,13 +538,15 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -548,19 +558,17 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -572,13 +580,15 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -590,19 +600,17 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -614,13 +622,15 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -632,19 +642,17 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -656,13 +664,15 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -674,19 +684,17 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -698,13 +706,15 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -716,19 +726,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -740,13 +748,15 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -758,19 +768,17 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -785,9 +793,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( platform_update_domain: int, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -799,59 +810,58 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -863,11 +873,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -897,9 +909,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -922,37 +934,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -969,17 +991,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -991,11 +1016,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1021,9 +1048,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1046,37 +1073,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1095,13 +1132,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1110,11 +1150,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1156,20 +1198,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1179,8 +1226,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1199,7 +1252,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1211,13 +1264,16 @@ def get( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1226,11 +1282,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1255,17 +1313,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1280,11 +1341,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1306,7 +1369,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1333,23 +1396,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1359,8 +1427,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1377,17 +1451,20 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1399,11 +1476,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1425,7 +1504,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -1449,23 +1528,28 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1475,8 +1559,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1495,7 +1585,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1507,13 +1597,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1522,11 +1615,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1552,7 +1647,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1564,13 +1659,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1579,9 +1677,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1590,9 +1690,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1629,7 +1731,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1641,13 +1743,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1655,9 +1760,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1665,9 +1772,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1706,7 +1815,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1721,13 +1830,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1737,9 +1849,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1749,9 +1863,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1790,7 +1906,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1804,13 +1920,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1820,9 +1939,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1832,9 +1953,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1871,17 +1994,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1896,11 +2022,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1922,7 +2050,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1949,23 +2077,28 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1975,8 +2108,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1993,17 +2132,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2018,11 +2160,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2044,7 +2188,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2069,23 +2213,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2095,8 +2244,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2113,17 +2268,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2138,11 +2296,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2164,7 +2324,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2189,23 +2349,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2215,8 +2380,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2233,17 +2404,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2258,11 +2432,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2284,7 +2460,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2310,23 +2486,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2336,8 +2517,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2354,17 +2541,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2379,11 +2569,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2405,7 +2597,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2433,23 +2625,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2459,8 +2656,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2477,17 +2680,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2499,11 +2705,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2525,7 +2733,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2549,23 +2757,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2575,8 +2788,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2593,17 +2812,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -2618,11 +2840,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2644,7 +2868,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -2670,23 +2894,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2696,8 +2925,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2714,17 +2949,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2739,11 +2977,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2765,7 +3005,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2791,23 +3031,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2817,8 +3062,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2838,7 +3089,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2854,13 +3105,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2018_10_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2870,11 +3124,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_sizes_operations.py index b3e278c4bd08..95db9cd4e72b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -99,13 +99,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machines_operations.py index 01c79897c6d0..f7594490460d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -201,8 +205,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -214,13 +219,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -233,9 +237,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -247,20 +254,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -271,9 +276,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -285,18 +293,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -307,8 +313,9 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -320,13 +327,12 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -337,8 +343,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -350,13 +357,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -367,8 +373,9 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -380,13 +387,12 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -396,9 +402,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -409,18 +418,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -429,9 +436,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -441,18 +451,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -463,9 +471,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -477,18 +488,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -499,8 +508,9 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -512,13 +522,12 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -529,8 +538,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -542,13 +552,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -559,8 +568,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -572,13 +582,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -589,8 +598,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -602,13 +612,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -618,13 +627,15 @@ def build_reimage_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -636,19 +647,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -661,8 +670,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -674,13 +684,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -690,14 +699,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -709,53 +721,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2018_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.compute.v2018_10_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -767,13 +775,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -782,9 +793,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -793,9 +806,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -832,17 +847,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -854,11 +872,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -886,9 +906,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -912,37 +932,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -959,17 +989,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -981,11 +1014,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1015,9 +1050,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1039,37 +1074,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1086,17 +1131,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1108,11 +1156,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1142,9 +1192,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1166,37 +1216,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1215,13 +1275,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1230,11 +1293,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1276,20 +1341,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1299,8 +1369,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1320,28 +1396,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1351,11 +1430,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1382,7 +1463,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1394,13 +1475,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2018_10_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1409,11 +1493,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1440,13 +1526,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1455,11 +1544,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1502,20 +1593,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1525,8 +1621,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1545,13 +1647,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -1560,11 +1665,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1607,20 +1714,25 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1630,8 +1742,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1662,13 +1780,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1677,11 +1798,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1703,7 +1826,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1716,13 +1839,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1731,9 +1857,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1742,9 +1870,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1781,7 +1911,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1792,13 +1922,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1806,9 +1939,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1816,9 +1951,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1857,7 +1994,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1872,13 +2009,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2018_10_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1888,9 +2028,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1900,9 +2042,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1941,13 +2085,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1956,11 +2103,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2003,20 +2152,25 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2026,8 +2180,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2046,13 +2206,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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', "2018-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2061,11 +2224,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2107,20 +2272,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2130,8 +2300,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2150,13 +2326,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2165,11 +2344,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2211,20 +2392,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2234,8 +2420,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2254,13 +2446,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2269,11 +2464,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2315,20 +2512,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2338,8 +2540,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2356,17 +2564,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -2381,11 +2592,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2407,7 +2620,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -2431,23 +2644,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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[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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -2457,8 +2675,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2477,13 +2701,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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 {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2492,11 +2719,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2538,20 +2767,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2561,8 +2795,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2579,18 +2819,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2602,11 +2845,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2634,11 +2879,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2647,7 +2892,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2018_10_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2663,36 +2908,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2018_10_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2018-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/_compute_management_client.py index 27b83b1611bb..83922e086768 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/_compute_management_client.py @@ -120,31 +120,81 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/_compute_management_client.py index 0e70fa2f1256..2ffb0552f861 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/_compute_management_client.py @@ -122,31 +122,81 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/__init__.py index 5d6e85ad6071..397bfbfc1ebd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/__init__.py @@ -32,6 +32,9 @@ from ._disks_operations import DisksOperations from ._snapshots_operations import SnapshotsOperations +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', 'AvailabilitySetsOperations', @@ -59,3 +62,5 @@ 'DisksOperations', 'SnapshotsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_availability_sets_operations.py index 036bf2048840..b6ff9564a425 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2019_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2019_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_dedicated_host_groups_operations.py index 8b81fc3c09df..ec13e7c56add 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_dedicated_host_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostGroupsOperations: - """DedicatedHostGroupsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2019_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -137,14 +141,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2019_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -156,11 +163,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -199,13 +208,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,11 +226,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,7 +255,7 @@ async def get( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -253,13 +267,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -268,11 +285,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -298,7 +317,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -311,13 +330,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -326,9 +348,11 @@ def prepare_request(next_link=None): 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: @@ -337,9 +361,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +402,7 @@ async def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -387,13 +413,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,9 +430,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -411,9 +442,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_dedicated_hosts_operations.py index 421a2ad9c65e..173b28d30025 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostsOperations: - """DedicatedHostsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('DedicatedHost', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -267,17 +286,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -285,20 +307,27 @@ async def begin_update( 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('DedicatedHost', 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( @@ -318,13 +347,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -334,11 +366,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,21 +417,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -407,8 +446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -429,7 +474,7 @@ async def get( host_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -438,21 +483,24 @@ async def get( :type host_group_name: str :param host_name: The name of the dedicated host. :type host_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedHost, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_03_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -463,11 +511,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -494,7 +544,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostListResult"]: + ) -> AsyncIterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -509,13 +559,16 @@ def list_by_host_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -525,9 +578,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -537,9 +592,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_disks_operations.py index 9e12ebeb51e7..a3ca6036c66b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_galleries_operations.py index c13472ff5eda..4116c915895b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleriesOperations: - """GalleriesOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -184,7 +198,7 @@ async def get( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -196,13 +210,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -211,11 +228,13 @@ async def get( gallery_name=gallery_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,13 +261,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -257,11 +279,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -303,20 +327,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -326,8 +355,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -345,7 +380,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -356,13 +391,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -371,9 +409,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -382,9 +422,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -421,7 +463,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -430,13 +472,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -444,9 +489,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -454,9 +501,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_application_versions_operations.py index 6fd0113ecf64..48ce17bc9ba2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationVersionsOperations: - """GalleryApplicationVersionsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -152,17 +156,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -171,20 +178,27 @@ async def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -206,7 +220,7 @@ async def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -227,13 +241,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -245,11 +262,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -278,13 +297,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -295,11 +317,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -350,22 +374,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -375,8 +404,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -396,7 +431,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationVersionList"]: + ) -> AsyncIterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -414,13 +449,16 @@ def list_by_gallery_application( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -431,9 +469,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -444,9 +484,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_applications_operations.py index 24af4929760b..f9a24640ff76 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationsOperations: - """GalleryApplicationsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -144,17 +148,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -162,20 +169,27 @@ async def begin_create_or_update( 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('GalleryApplication', 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( @@ -195,7 +209,7 @@ async def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -211,13 +225,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -227,11 +244,13 @@ async def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -259,13 +278,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -275,11 +297,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -325,21 +349,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -349,8 +378,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -369,7 +404,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationList"]: + ) -> AsyncIterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -384,13 +419,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -400,9 +438,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -412,9 +452,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_image_versions_operations.py index 74d49d76f3cc..9f81e7f473d9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImageVersionsOperations: - """GalleryImageVersionsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Create or update a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -151,17 +155,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -170,20 +177,27 @@ async def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -205,7 +219,7 @@ async def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -225,13 +239,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -243,11 +260,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -276,13 +295,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -293,11 +315,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,22 +371,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -372,8 +401,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -393,7 +428,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageVersionList"]: + ) -> AsyncIterable[_models.GalleryImageVersionList]: """List gallery Image Versions in a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -411,13 +446,16 @@ def list_by_gallery_image( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -428,9 +466,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -441,9 +481,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_images_operations.py index 361070478ba6..48aa4cda62fa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImagesOperations: - """GalleryImagesOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Create or update a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -160,20 +167,27 @@ async def begin_create_or_update( 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('GalleryImage', 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( @@ -193,7 +207,7 @@ async def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -208,13 +222,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -224,11 +241,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -256,13 +275,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -272,11 +294,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -322,21 +346,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -346,8 +375,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -366,7 +401,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageList"]: + ) -> AsyncIterable[_models.GalleryImageList]: """List gallery Image Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -380,13 +415,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -396,9 +434,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -408,9 +448,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_images_operations.py index 51214c010637..5aa4bb03187d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_log_analytics_operations.py index 382e8492225e..34f96f3b38da 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_operations.py index c34642961d97..2ccce06a6bfc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_proximity_placement_groups_operations.py index 56897f29790d..e0806dcdb88f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2019_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2019_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -239,7 +253,7 @@ async def get( resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -251,13 +265,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -266,11 +283,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -295,7 +314,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -319,9 +341,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -329,9 +353,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -369,7 +395,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -381,13 +407,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -396,9 +425,11 @@ def prepare_request(next_link=None): 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: @@ -407,9 +438,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_snapshots_operations.py index d0b6f94b8e69..79fae7d9fef3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_usage_operations.py index df3531a0f181..4bf78a695f5e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_extension_images_operations.py index ee4d2687430f..604bae4c979d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_extensions_operations.py index 9240e1308e64..73d308791d7d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_images_operations.py index 94ec04349d45..91a473862034 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_run_commands_operations.py index 02b657599992..606b2c231fc8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -15,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 @@ -24,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,7 +135,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -141,13 +147,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -156,11 +165,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index 7bd0faa1a11f..2043a585b675 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -191,13 +205,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -207,11 +224,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -256,21 +275,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -280,8 +304,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -302,7 +332,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -318,13 +348,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -335,11 +368,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,7 +401,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -380,13 +415,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -396,9 +434,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -408,9 +448,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index a8a0dbe9cbe0..17d521fad49d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,13 +292,16 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu vm_scale_set_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -276,11 +310,13 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,20 +360,25 @@ async def begin_start_extension_upgrade( # pylint: disable=inconsistent-return- :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_extension_upgrade_initial( + raw_result = await self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -347,8 +388,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -367,7 +414,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -379,13 +426,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2019_03_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -394,11 +444,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index beba07c861ae..3c17bad8a3a3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -78,11 +80,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -132,17 +136,20 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -150,6 +157,8 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,13 +195,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -196,11 +214,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,21 +266,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -270,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -291,13 +322,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -307,11 +341,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,21 +394,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -382,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -401,17 +448,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -424,11 +474,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,9 +511,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -487,17 +539,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -505,20 +560,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -538,13 +600,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -554,11 +619,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -603,21 +670,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -627,8 +699,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -649,7 +727,7 @@ async def get( instance_id: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -658,21 +736,24 @@ async def get( :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. :type instance_id: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachineScaleSetVM, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -683,11 +764,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -715,7 +798,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -729,13 +812,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -745,11 +831,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -779,7 +867,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -803,13 +891,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -822,9 +913,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -837,9 +930,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -880,13 +975,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -897,11 +995,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -953,22 +1053,27 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -978,8 +1083,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -999,13 +1110,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1015,11 +1129,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1064,21 +1180,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1088,8 +1209,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1109,13 +1236,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1125,11 +1255,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1174,21 +1306,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1198,8 +1335,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1219,13 +1362,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1235,11 +1381,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1285,21 +1433,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1309,8 +1462,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1330,13 +1489,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1346,11 +1508,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1395,21 +1559,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1419,8 +1588,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1438,18 +1613,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1462,11 +1640,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1495,11 +1675,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1510,7 +1690,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2019_03_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1527,16 +1707,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1544,20 +1727,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_sets_operations.py index d0194d8f83bf..c9d30cc7b14c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -231,9 +250,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -409,7 +454,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -421,13 +466,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -436,11 +484,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -465,17 +515,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -490,11 +543,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -516,7 +571,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -543,23 +598,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -569,8 +629,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -587,17 +653,20 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -609,11 +678,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,7 +706,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -659,23 +730,28 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +761,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +787,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -717,13 +799,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -732,11 +817,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -762,7 +849,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -774,13 +861,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -789,9 +879,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -800,9 +892,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -839,7 +933,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -851,13 +945,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -865,9 +962,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -875,9 +974,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +1017,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -931,13 +1032,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -947,9 +1051,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -959,9 +1065,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1000,7 +1108,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1014,13 +1122,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1030,9 +1141,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1042,9 +1155,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1082,17 +1197,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1108,11 +1226,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1135,7 +1255,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1166,17 +1286,20 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -1184,6 +1307,8 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1193,8 +1318,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1211,17 +1342,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1236,11 +1370,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1262,7 +1398,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1287,23 +1423,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1313,8 +1454,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1331,17 +1478,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1356,11 +1506,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1382,7 +1534,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1407,23 +1559,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1433,8 +1590,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1451,17 +1614,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1476,11 +1642,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1502,7 +1670,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1528,23 +1696,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1554,8 +1727,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1572,17 +1751,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1597,11 +1779,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1623,7 +1807,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1651,23 +1835,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1677,8 +1866,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1695,17 +1890,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1717,11 +1915,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1743,7 +1943,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1767,23 +1967,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1793,8 +1998,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1811,17 +2022,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -1836,11 +2050,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1862,7 +2078,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -1888,23 +2104,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1914,8 +2135,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1932,17 +2159,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1957,11 +2187,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1983,7 +2215,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2009,23 +2241,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2035,8 +2272,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2056,7 +2299,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2072,13 +2315,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2019_03_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2088,11 +2334,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2118,7 +2366,7 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to true for a existing virtual machine scale set. @@ -2135,14 +2383,17 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret :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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -2154,11 +2405,13 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_sizes_operations.py index 08ffd7de1777..8e92128b9945 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machines_operations.py index e01a65afd32c..f65470e80f25 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -337,37 +363,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -384,17 +420,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -406,11 +445,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -440,9 +481,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -465,37 +506,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -514,13 +565,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -529,11 +583,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -575,20 +631,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -598,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -619,28 +686,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -650,11 +720,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -681,7 +753,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -693,13 +765,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -708,11 +783,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -739,13 +816,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -754,11 +834,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -801,20 +883,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -824,8 +911,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -844,13 +937,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -859,11 +955,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -906,20 +1004,25 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -929,8 +1032,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -961,13 +1070,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -976,11 +1088,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1002,7 +1116,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1015,13 +1129,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1030,9 +1147,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1041,9 +1160,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1080,7 +1201,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1091,13 +1212,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1105,9 +1229,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1115,9 +1241,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1156,7 +1284,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1171,13 +1299,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1187,9 +1318,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1199,9 +1332,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1241,13 +1376,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1257,11 +1395,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1309,21 +1449,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1333,8 +1478,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1353,13 +1504,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1368,11 +1522,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1414,20 +1570,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1437,8 +1598,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1457,13 +1624,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1472,11 +1642,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1518,20 +1690,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1541,8 +1718,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1561,13 +1744,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1576,11 +1762,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1622,20 +1810,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1645,8 +1838,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1663,17 +1862,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -1688,11 +1890,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1714,7 +1918,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -1738,23 +1942,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -1764,8 +1973,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1784,13 +1999,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1799,11 +2017,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1845,20 +2065,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1868,8 +2093,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1886,18 +2117,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1909,11 +2143,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1941,11 +2177,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -1954,7 +2190,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2019_03_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1971,36 +2207,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_03_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/__init__.py index 2ad1f9f69db5..aa223ea74fe3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/__init__.py @@ -267,7 +267,9 @@ VirtualMachineScaleSetSkuScaleType, VirtualMachineSizeTypes, ) - +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__ = [ 'AccessUri', 'AdditionalCapabilities', @@ -527,3 +529,5 @@ 'VirtualMachineScaleSetSkuScaleType', 'VirtualMachineSizeTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/_compute_management_client_enums.py index a161f3e044a6..5a0f7ba48fb3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/_compute_management_client_enums.py @@ -7,17 +7,16 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" WRITE = "Write" -class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the aggregated replication status based on all the regional replication status flags. """ @@ -26,7 +25,7 @@ class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, En COMPLETED = "Completed" FAILED = "Failed" -class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. """ @@ -34,7 +33,7 @@ class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CLASSIC = "Classic" ALIGNED = "Aligned" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -45,7 +44,7 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the software license type that will be applied to the VMs deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` @@ -56,13 +55,13 @@ class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" -class DiffDiskOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk option for operating system disk. """ LOCAL = "Local" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -84,7 +83,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the disk. UPLOAD = "Upload" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -97,7 +96,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the disk. """ @@ -114,7 +113,7 @@ class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: A disk is created for upload and a write token has been issued for uploading to it. ACTIVE_UPLOAD = "ActiveUpload" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -129,7 +128,7 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: databases (for example, SQL, Oracle), and other transaction-heavy workloads. ULTRA_SSD_LRS = "UltraSSD_LRS" -class GalleryApplicationVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryApplicationVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -140,7 +139,7 @@ class GalleryApplicationVersionPropertiesProvisioningState(with_metaclass(CaseIn DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImagePropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -151,7 +150,7 @@ class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnum DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImageVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -162,7 +161,7 @@ class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensit DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -173,7 +172,7 @@ class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, DELETING = "Deleting" MIGRATING = "Migrating" -class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite' """ @@ -181,28 +180,28 @@ class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class HyperVGenerationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type associated with a resource """ V1 = "V1" V2 = "V2" -class HyperVGenerationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type """ V1 = "V1" V2 = "V2" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -211,7 +210,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -220,7 +219,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -229,7 +228,7 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ @@ -238,14 +237,14 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: Specialized image. Contains already provisioned OS Disk. SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -253,7 +252,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -262,7 +261,7 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the regional replication state. """ @@ -271,11 +270,11 @@ class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAILED = "Failed" -class ReplicationStatusTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): REPLICATION_STATUS = "ReplicationStatus" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -286,14 +285,14 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -302,7 +301,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -310,7 +309,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -321,7 +320,7 @@ class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E #: Standard zone redundant storage. STANDARD_ZRS = "Standard_ZRS" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -329,7 +328,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type to be used to store the image. This property is not updatable. """ @@ -337,7 +336,7 @@ class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_LRS = "Standard_LRS" STANDARD_ZRS = "Standard_ZRS" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. StandardSSD_LRS uses Standard SSD. Premium_LRS uses Premium SSD. UltraSSD_LRS uses Ultra disk. @@ -352,7 +351,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_SSD_LRS = "StandardSSD_LRS" ULTRA_SSD_LRS = "UltraSSD_LRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -364,7 +363,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -372,7 +371,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -381,14 +380,14 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for the Azure Spot VM/VMSS """ DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for a standalone virtual machine or the virtual machines in the scale set. :code:`
`:code:`
` 'Low' enum will be deprecated in the future, please use 'Spot' as the enum to deploy Azure Spot VM/VMSS. @@ -398,20 +397,20 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E LOW = "Low" SPOT = "Spot" -class VirtualMachineScaleSetScaleInRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "Default" OLDEST_VM = "OldestVM" NEWEST_VM = "NewestVM" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. For more information about virtual machine sizes, see `Sizes for virtual machines `_. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/_models_py3.py index fc7958de0284..ee11a13d1ac7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -83,7 +85,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2019_03_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -104,7 +106,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -117,7 +119,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2019_03_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -185,8 +187,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -488,11 +490,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -550,7 +552,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -632,11 +634,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -870,8 +872,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :vartype create_option: str or ~azure.mgmt.compute.v2019_03_01.models.DiskCreateOption :ivar storage_account_id: If createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in a @@ -912,9 +914,9 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, upload_size_bytes: Optional[int] = None, @@ -922,7 +924,7 @@ def __init__( ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :paramtype create_option: str or ~azure.mgmt.compute.v2019_03_01.models.DiskCreateOption :keyword storage_account_id: If createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in @@ -971,8 +973,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -983,7 +984,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2019_03_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1018,14 +1019,14 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, to_be_detached: Optional[bool] = None, **kwargs ): @@ -1045,8 +1046,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1057,7 +1057,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2019_03_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1144,7 +1144,7 @@ class DedicatedHost(Resource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2019_03_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1189,11 +1189,11 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1214,7 +1214,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2019_03_01.models.DedicatedHostLicenseTypes """ @@ -1280,7 +1280,7 @@ class DedicatedHostAvailableCapacity(msrest.serialization.Model): def __init__( self, *, - allocatable_v_ms: Optional[List["DedicatedHostAllocatableVM"]] = None, + allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs ): """ @@ -1391,7 +1391,7 @@ class DedicatedHostGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHostGroup"], + value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs ): @@ -1488,8 +1488,8 @@ class DedicatedHostInstanceView(msrest.serialization.Model): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1529,7 +1529,7 @@ class DedicatedHostListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHost"], + value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs ): @@ -1566,7 +1566,7 @@ class DedicatedHostUpdate(UpdateResource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2019_03_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1603,7 +1603,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1619,7 +1619,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2019_03_01.models.DedicatedHostLicenseTypes """ @@ -1651,7 +1651,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -1668,8 +1668,8 @@ def __init__( class DiffDiskSettings(msrest.serialization.Model): """Describes the parameters of ephemeral disk settings that can be specified for operating system disk. :code:`
`:code:`
` NOTE: The ephemeral disk settings can only be specified for managed disk. - :ivar option: Specifies the ephemeral disk settings for operating system disk. Possible values - include: "Local". + :ivar option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :vartype option: str or ~azure.mgmt.compute.v2019_03_01.models.DiffDiskOptions """ @@ -1680,12 +1680,12 @@ class DiffDiskSettings(msrest.serialization.Model): def __init__( self, *, - option: Optional[Union[str, "DiffDiskOptions"]] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, **kwargs ): """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. Possible - values include: "Local". + :keyword option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :paramtype option: str or ~azure.mgmt.compute.v2019_03_01.models.DiffDiskOptions """ super(DiffDiskSettings, self).__init__(**kwargs) @@ -1743,10 +1743,10 @@ class Disk(Resource): :vartype zones: list[str] :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_03_01.models.HyperVGeneration :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1773,7 +1773,7 @@ class Disk(Resource): disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. :vartype disk_m_bps_read_write: int - :ivar disk_state: The state of the disk. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", "Reserved", "ActiveSAS", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2019_03_01.models.DiskState """ @@ -1819,13 +1819,13 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - creation_data: Optional["CreationData"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -1840,10 +1840,10 @@ def __init__( :paramtype sku: ~azure.mgmt.compute.v2019_03_01.models.DiskSku :keyword zones: The Logical zone list for Disk. :paramtype zones: list[str] - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_03_01.models.HyperVGeneration :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1904,8 +1904,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -1947,8 +1947,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1991,7 +1991,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -2012,8 +2012,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS". :vartype name: str or ~azure.mgmt.compute.v2019_03_01.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -2031,11 +2031,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype name: str or ~azure.mgmt.compute.v2019_03_01.models.DiskStorageAccountTypes """ @@ -2052,7 +2052,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :vartype sku: ~azure.mgmt.compute.v2019_03_01.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -2086,10 +2086,10 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -2100,7 +2100,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :paramtype sku: ~azure.mgmt.compute.v2019_03_01.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -2162,7 +2162,7 @@ def __init__( self, *, enabled: bool, - encryption_settings: Optional[List["EncryptionSettingsElement"]] = None, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, encryption_settings_version: Optional[str] = None, **kwargs ): @@ -2204,8 +2204,8 @@ class EncryptionSettingsElement(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -2243,8 +2243,8 @@ class Gallery(Resource): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2019_03_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_03_01.models.GalleryPropertiesProvisioningState """ @@ -2274,7 +2274,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, **kwargs ): """ @@ -2325,8 +2325,8 @@ class GalleryApplication(Resource): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes """ @@ -2361,7 +2361,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -2383,8 +2383,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes """ @@ -2421,7 +2421,7 @@ class GalleryApplicationList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplication"], + value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs ): @@ -2458,8 +2458,8 @@ class GalleryApplicationVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2019_03_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_03_01.models.GalleryApplicationVersionPropertiesProvisioningState :ivar replication_status: This is the replication status of the gallery Image Version. @@ -2491,7 +2491,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -2533,7 +2533,7 @@ class GalleryApplicationVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplicationVersion"], + value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs ): @@ -2570,7 +2570,7 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountType """ @@ -2590,11 +2590,11 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, **kwargs ): """ @@ -2612,7 +2612,7 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountType """ @@ -2648,7 +2648,7 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountType :ivar source: Required. The source image from which the Image Version is going to be created. :vartype source: ~azure.mgmt.compute.v2019_03_01.models.UserArtifactSource @@ -2678,13 +2678,13 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil def __init__( self, *, - source: "UserArtifactSource", - target_regions: Optional[List["TargetRegion"]] = None, + source: "_models.UserArtifactSource", + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - manage_actions: Optional["UserArtifactManage"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + manage_actions: Optional["_models.UserArtifactManage"] = None, enable_health_check: Optional[bool] = None, **kwargs ): @@ -2703,7 +2703,7 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountType :keyword source: Required. The source image from which the Image Version is going to be @@ -2740,7 +2740,7 @@ class GalleryArtifactSource(msrest.serialization.Model): def __init__( self, *, - managed_image: "ManagedArtifact", + managed_image: "_models.ManagedArtifact", **kwargs ): """ @@ -2759,7 +2759,7 @@ class GalleryDiskImage(msrest.serialization.Model): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2019_03_01.models.HostCaching """ @@ -2792,7 +2792,7 @@ class GalleryDataDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2019_03_01.models.HostCaching :ivar lun: This property specifies the logical unit number of the data disk. This value is used to identify data disks within the Virtual Machine and therefore must be unique for each data @@ -2878,11 +2878,11 @@ class GalleryImage(Resource): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemStateTypes :ivar end_of_life_date: The end of life date of the gallery Image Definition. This property can @@ -2898,8 +2898,8 @@ class GalleryImage(Resource): :ivar purchase_plan: Describes the gallery Image Definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2019_03_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_03_01.models.GalleryImagePropertiesProvisioningState """ @@ -2941,13 +2941,13 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, **kwargs ): """ @@ -2966,12 +2966,12 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemStateTypes :keyword end_of_life_date: The end of life date of the gallery Image Definition. This property can be used for decommissioning purposes. This property is updatable. @@ -3073,7 +3073,7 @@ class GalleryImageList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImage"], + value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs ): @@ -3109,8 +3109,8 @@ class GalleryImageVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery Image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2019_03_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_03_01.models.GalleryImageVersionPropertiesProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -3147,7 +3147,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, **kwargs ): """ @@ -3190,7 +3190,7 @@ class GalleryImageVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImageVersion"], + value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs ): @@ -3229,7 +3229,7 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountType :ivar source: Required. The source image from which the Image Version is going to be created. :vartype source: ~azure.mgmt.compute.v2019_03_01.models.GalleryArtifactSource @@ -3253,12 +3253,12 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) def __init__( self, *, - source: "GalleryArtifactSource", - target_regions: Optional[List["TargetRegion"]] = None, + source: "_models.GalleryArtifactSource", + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, **kwargs ): """ @@ -3276,7 +3276,7 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountType :keyword source: Required. The source image from which the Image Version is going to be @@ -3343,7 +3343,7 @@ class GalleryList(msrest.serialization.Model): def __init__( self, *, - value: List["Gallery"], + value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs ): @@ -3367,7 +3367,7 @@ class GalleryOSDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2019_03_01.models.HostCaching """ @@ -3395,7 +3395,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read", "Write". + :ivar access: Required. Known values are: "None", "Read", "Write". :vartype access: str or ~azure.mgmt.compute.v2019_03_01.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -3414,12 +3414,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read", "Write". + :keyword access: Required. Known values are: "None", "Read", "Write". :paramtype access: str or ~azure.mgmt.compute.v2019_03_01.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -3442,8 +3442,8 @@ class HardwareProfile(msrest.serialization.Model): :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -3488,7 +3488,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -3502,8 +3502,8 @@ def __init__( :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -3568,7 +3568,7 @@ class Image(Resource): :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Possible values include: "V1", "V2". + image. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_03_01.models.HyperVGenerationTypes """ @@ -3598,9 +3598,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -3613,7 +3613,7 @@ def __init__( :keyword storage_profile: Specifies the storage settings for the virtual machine disks. :paramtype storage_profile: ~azure.mgmt.compute.v2019_03_01.models.ImageStorageProfile :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Possible values include: "V1", "V2". + the image. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_03_01.models.HyperVGenerationTypes """ @@ -3642,16 +3642,15 @@ class ImageDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountTypes """ @@ -3674,12 +3673,12 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ @@ -3696,16 +3695,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountTypes """ @@ -3785,7 +3783,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -3808,10 +3806,10 @@ class ImageOSDisk(msrest.serialization.Model): :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemStateTypes :ivar snapshot: The snapshot. :vartype snapshot: ~azure.mgmt.compute.v2019_03_01.models.SubResource @@ -3822,16 +3820,15 @@ class ImageOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. - UltraSSD_LRS cannot be used with OS Disk. Possible values include: "Standard_LRS", - "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", + "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountTypes """ @@ -3855,24 +3852,23 @@ class ImageOSDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemStateTypes :keyword snapshot: The snapshot. :paramtype snapshot: ~azure.mgmt.compute.v2019_03_01.models.SubResource @@ -3883,16 +3879,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. - UltraSSD_LRS cannot be used with OS Disk. Possible values include: "Standard_LRS", - "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", + "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountTypes """ @@ -4060,8 +4055,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -4100,7 +4095,7 @@ class ImageUpdate(UpdateResource): :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Possible values include: "V1", "V2". + image. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_03_01.models.HyperVGenerationTypes """ @@ -4121,9 +4116,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -4134,7 +4129,7 @@ def __init__( :keyword storage_profile: Specifies the storage settings for the virtual machine disks. :paramtype storage_profile: ~azure.mgmt.compute.v2019_03_01.models.ImageStorageProfile :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Possible values include: "V1", "V2". + the image. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_03_01.models.HyperVGenerationTypes """ @@ -4182,7 +4177,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2019_03_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -4204,7 +4199,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -4213,7 +4208,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2019_03_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -4254,7 +4249,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -4293,7 +4288,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -4333,7 +4328,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -4372,7 +4367,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -4411,7 +4406,7 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, provision_vm_agent: Optional[bool] = None, **kwargs ): @@ -4457,7 +4452,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -4611,8 +4606,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2019_03_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -4637,7 +4632,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -4653,8 +4648,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2019_03_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -4707,8 +4702,8 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountTypes """ @@ -4722,15 +4717,15 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountTypes """ @@ -4787,7 +4782,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -4807,8 +4802,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -4824,8 +4819,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -4839,7 +4833,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2019_03_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -4870,24 +4864,24 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -4903,8 +4897,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -4918,7 +4911,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2019_03_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -4946,8 +4939,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes """ @@ -4962,12 +4955,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -5061,9 +5054,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, require_guest_provision_signal: Optional[bool] = None, **kwargs @@ -5215,7 +5208,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2019_03_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -5256,7 +5249,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, **kwargs ): """ @@ -5267,7 +5260,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2019_03_01.models.ProximityPlacementGroupType """ @@ -5301,7 +5294,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -5406,8 +5399,8 @@ class RecommendedMachineConfiguration(msrest.serialization.Model): def __init__( self, *, - v_cp_us: Optional["ResourceRange"] = None, - memory: Optional["ResourceRange"] = None, + v_cp_us: Optional["_models.ResourceRange"] = None, + memory: Optional["_models.ResourceRange"] = None, **kwargs ): """ @@ -5461,7 +5454,7 @@ class RegionalReplicationStatus(msrest.serialization.Model): :ivar region: The region to which the gallery Image Version is being replicated to. :vartype region: str - :ivar state: This is the regional replication state. Possible values include: "Unknown", + :ivar state: This is the regional replication state. Known values are: "Unknown", "Replicating", "Completed", "Failed". :vartype state: str or ~azure.mgmt.compute.v2019_03_01.models.ReplicationState :ivar details: The details of the replication status. @@ -5503,8 +5496,7 @@ class ReplicationStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Possible values include: "Unknown", "InProgress", "Completed", - "Failed". + replication status flags. Known values are: "Unknown", "InProgress", "Completed", "Failed". :vartype aggregated_state: str or ~azure.mgmt.compute.v2019_03_01.models.AggregatedReplicationState :ivar summary: This is a summary of replication status for each region. @@ -5551,7 +5543,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_resource_name: Group query result by Resource Name. :vartype group_by_resource_name: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2019_03_01.models.IntervalInMins """ @@ -5578,7 +5570,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -5599,7 +5591,7 @@ def __init__( :keyword group_by_resource_name: Group query result by Resource Name. :paramtype group_by_resource_name: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2019_03_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, **kwargs) @@ -5800,13 +5792,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2019_03_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2019_03_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -5919,8 +5911,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -5949,7 +5940,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -5959,8 +5950,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -5984,8 +5974,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -6021,11 +6010,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -6033,8 +6022,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -6080,7 +6068,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -6161,7 +6149,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -6244,7 +6232,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -6283,7 +6271,7 @@ class ScaleInPolicy(msrest.serialization.Model): def __init__( self, *, - rules: Optional[List[Union[str, "VirtualMachineScaleSetScaleInRules"]]] = None, + rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, **kwargs ): """ @@ -6324,7 +6312,7 @@ class ScheduledEventsProfile(msrest.serialization.Model): def __init__( self, *, - terminate_notification_profile: Optional["TerminateNotificationProfile"] = None, + terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs ): """ @@ -6403,10 +6391,10 @@ class Snapshot(Resource): :vartype sku: ~azure.mgmt.compute.v2019_03_01.models.SnapshotSku :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_03_01.models.HyperVGeneration :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -6468,12 +6456,12 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, incremental: Optional[bool] = None, **kwargs ): @@ -6484,10 +6472,10 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2019_03_01.models.SnapshotSku - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_03_01.models.HyperVGeneration :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -6544,7 +6532,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -6565,8 +6553,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2019_03_01.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -6584,12 +6571,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2019_03_01.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -6604,7 +6590,7 @@ class SnapshotUpdate(msrest.serialization.Model): :vartype tags: dict[str, str] :ivar sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :vartype sku: ~azure.mgmt.compute.v2019_03_01.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -6629,10 +6615,10 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, **kwargs ): """ @@ -6640,7 +6626,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2019_03_01.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -6699,7 +6685,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -6781,9 +6767,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -6847,7 +6833,7 @@ class TargetRegion(msrest.serialization.Model): region. This property is updatable. :vartype regional_replica_count: int :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountType """ @@ -6866,7 +6852,7 @@ def __init__( *, name: str, regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, **kwargs ): """ @@ -6876,7 +6862,7 @@ def __init__( region. This property is updatable. :paramtype regional_replica_count: int :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountType """ @@ -7037,7 +7023,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2019_03_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2019_03_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2019_03_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -7084,7 +7070,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2019_03_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -7124,8 +7110,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2019_03_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -7145,9 +7131,9 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["AutomaticOSUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, + automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, **kwargs ): """ @@ -7155,8 +7141,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2019_03_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -7210,7 +7196,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -7460,8 +7446,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -7570,11 +7556,11 @@ class VirtualMachine(Resource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_03_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine. Only - supported value is 'Deallocate'. :code:`
`:code:`
`Minimum api-version: 2019-03-01. - Possible values include: "Deallocate", "Delete". + supported value is 'Deallocate'. :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known + values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -7646,22 +7632,22 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -7720,12 +7706,12 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_03_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine. Only supported value is 'Deallocate'. :code:`
`:code:`
`Minimum api-version: 2019-03-01. - Possible values include: "Deallocate", "Delete". + Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -7790,8 +7776,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -7987,7 +7973,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -8052,7 +8038,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -8189,8 +8175,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -8227,7 +8213,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -8359,8 +8345,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2019_03_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -8384,15 +8370,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2019_03_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -8488,8 +8474,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2019_03_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: "V1", - "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_03_01.models.HyperVGenerationTypes """ @@ -8518,11 +8503,11 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, + automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -8547,8 +8532,7 @@ def __init__( image. :paramtype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2019_03_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: - "V1", "V2". + :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_03_01.models.HyperVGenerationTypes """ @@ -8573,8 +8557,8 @@ class VirtualMachineInstanceView(msrest.serialization.Model): :vartype os_name: str :ivar os_version: The version of Operating System running on the virtual machine. :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_03_01.models.HyperVGenerationType :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. :vartype rdp_thumb_print: str @@ -8621,14 +8605,14 @@ def __init__( computer_name: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationType"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -8643,7 +8627,7 @@ def __init__( :keyword os_version: The version of Operating System running on the virtual machine. :paramtype os_version: str :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_03_01.models.HyperVGenerationType :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. @@ -8706,7 +8690,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -8858,21 +8842,21 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, **kwargs ): """ @@ -8964,14 +8948,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2019_03_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -9001,12 +8984,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -9019,14 +9002,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2019_03_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -9175,7 +9157,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -9206,7 +9188,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs ): """ @@ -9232,7 +9214,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2019_03_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine @@ -9257,15 +9239,15 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2019_03_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual @@ -9343,7 +9325,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -9403,7 +9385,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2019_03_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -9447,14 +9429,14 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -9472,7 +9454,7 @@ def __init__( ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2019_03_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -9563,7 +9545,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -9604,7 +9586,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -9644,7 +9626,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -9684,7 +9666,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -9705,8 +9687,8 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can - only be used with data disks, it cannot be used with OS Disk. Possible values include: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", + "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountTypes """ @@ -9718,13 +9700,13 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS - can only be used with data disks, it cannot be used with OS Disk. Possible values include: + can only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_03_01.models.StorageAccountTypes @@ -9782,9 +9764,9 @@ def __init__( id: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -9865,8 +9847,8 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -9893,8 +9875,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -9903,8 +9884,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2019_03_01.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -9915,8 +9896,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2019_03_01.models.VirtualHardDisk @@ -9948,16 +9929,16 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -9966,8 +9947,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -9976,8 +9956,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2019_03_01.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -9989,7 +9969,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_03_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2019_03_01.models.VirtualHardDisk @@ -10088,9 +10068,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -10194,9 +10174,9 @@ def __init__( *, name: str, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -10366,8 +10346,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -10429,9 +10408,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -10522,18 +10501,18 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - proximity_placement_group: Optional["SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -10611,7 +10590,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2019_03_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -10645,14 +10624,14 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -10670,7 +10649,7 @@ def __init__( ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2019_03_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -10741,9 +10720,9 @@ def __init__( name: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -10798,8 +10777,8 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, **kwargs ): """ @@ -10819,7 +10798,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -10851,16 +10830,16 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -10912,9 +10891,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -10957,7 +10936,7 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, **kwargs ): """ @@ -10996,9 +10975,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -11057,14 +11036,14 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, **kwargs ): """ @@ -11239,17 +11218,17 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - network_profile_configuration: Optional["VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, - protection_policy: Optional["VirtualMachineScaleSetVMProtectionPolicy"] = None, + protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, **kwargs ): """ @@ -11482,12 +11461,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -11557,7 +11536,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -11588,7 +11567,7 @@ class VirtualMachineScaleSetVMNetworkProfileConfiguration(msrest.serialization.M def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -11630,11 +11609,11 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for virtual machines in a Azure Spot scale - set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: + set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineEvictionPolicyTypes @@ -11662,16 +11641,16 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, **kwargs ): """ @@ -11702,12 +11681,12 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for virtual machines in a Azure Spot - scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values - include: "Deallocate", "Delete". + scale set. :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: + "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -11846,7 +11825,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -11945,11 +11924,11 @@ class VirtualMachineUpdate(UpdateResource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_03_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine. Only - supported value is 'Deallocate'. :code:`
`:code:`
`Minimum api-version: 2019-03-01. - Possible values include: "Deallocate", "Delete". + supported value is 'Deallocate'. :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known + values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -12010,22 +11989,22 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -12082,12 +12061,12 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_03_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine. Only supported value is 'Deallocate'. :code:`
`:code:`
`Minimum api-version: 2019-03-01. - Possible values include: "Deallocate", "Delete". + Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -12197,8 +12176,8 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -12244,7 +12223,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -12259,8 +12238,8 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :vartype protocol: str or ~azure.mgmt.compute.v2019_03_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault @@ -12280,14 +12259,14 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of listener. :code:`
`:code:`
` Possible values - are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: - "Http", "Https". + are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", + "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2019_03_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as a secret. For adding a secret to the Key Vault, see `Add a key or secret to the key vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/__init__.py index 5d6e85ad6071..397bfbfc1ebd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/__init__.py @@ -32,6 +32,9 @@ from ._disks_operations import DisksOperations from ._snapshots_operations import SnapshotsOperations +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', 'AvailabilitySetsOperations', @@ -59,3 +62,5 @@ 'DisksOperations', 'SnapshotsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_availability_sets_operations.py index bf31d019f2b1..eae54566f0a9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +190,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -199,20 +205,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -235,18 +242,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -257,9 +262,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -271,51 +279,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -329,14 +333,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2019_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -348,11 +355,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -378,9 +387,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -394,14 +403,17 @@ def update( :rtype: ~azure.mgmt.compute.v2019_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -413,11 +425,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,13 +470,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -471,11 +488,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -498,7 +517,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -510,13 +529,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -525,11 +547,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -555,7 +579,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -568,13 +592,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -583,9 +610,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +623,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -634,7 +665,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -646,13 +677,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +695,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -672,9 +708,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -713,7 +751,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -728,13 +766,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -756,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_dedicated_host_groups_operations.py index d4448f57a103..8302998e7962 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_dedicated_host_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -186,9 +189,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -199,18 +205,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -219,9 +223,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") path_format_arguments = { @@ -231,51 +238,47 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostGroupsOperations(object): - """DedicatedHostGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -291,14 +294,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2019_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -310,11 +316,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -344,9 +352,9 @@ def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -360,14 +368,17 @@ def update( :rtype: ~azure.mgmt.compute.v2019_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -379,11 +390,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -422,13 +435,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -437,11 +453,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -464,7 +482,7 @@ def get( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -476,13 +494,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -491,11 +512,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -521,7 +544,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -534,13 +557,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -549,9 +575,11 @@ def prepare_request(next_link=None): 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: @@ -560,9 +588,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -599,7 +629,7 @@ def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -610,13 +640,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -624,9 +657,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -634,9 +669,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_dedicated_hosts_operations.py index 6f0fd1ae8331..79f6a1e0053f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHost] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_by_host_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_by_host_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostsOperations(object): - """DedicatedHostsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -341,17 +348,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -359,20 +369,27 @@ def begin_create_or_update( 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('DedicatedHost', 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( @@ -390,17 +407,20 @@ def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -413,11 +433,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -444,9 +466,9 @@ def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -470,17 +492,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -488,20 +513,27 @@ def begin_update( 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('DedicatedHost', 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( @@ -521,13 +553,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements host_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -537,11 +572,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -586,21 +623,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -610,8 +652,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -632,7 +680,7 @@ def get( host_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -641,21 +689,24 @@ def get( :type host_group_name: str :param host_name: The name of the dedicated host. :type host_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedHost, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_03_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -666,11 +717,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +750,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostListResult"]: + ) -> Iterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -712,13 +765,16 @@ def list_by_host_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -728,9 +784,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -740,9 +798,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_disks_operations.py index 00bb23bdad54..f23622f22a37 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_galleries_operations.py index 5f3dc04ae870..74b43aa5f0b2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.Gallery] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,9 +80,12 @@ def build_get_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -93,18 +97,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -115,9 +117,12 @@ def build_delete_request_initial( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -129,18 +134,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -150,9 +153,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries") # pylint: disable=line-too-long path_format_arguments = { @@ -163,18 +169,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -183,9 +187,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") path_format_arguments = { @@ -195,58 +202,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleriesOperations(object): - """GalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -258,11 +264,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -295,9 +303,9 @@ def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -319,37 +327,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -368,7 +386,7 @@ def get( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -380,13 +398,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -395,11 +416,13 @@ def get( gallery_name=gallery_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -426,13 +449,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -441,11 +467,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -487,20 +515,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -510,8 +543,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -529,7 +568,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -539,13 +578,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +596,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -565,9 +609,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -604,7 +650,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -612,13 +658,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -626,9 +675,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -636,9 +687,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_application_versions_operations.py index b605e0a07de0..9d42e21c991b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -87,9 +88,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -103,20 +107,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -129,9 +131,12 @@ def build_delete_request_initial( gallery_application_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -145,18 +150,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -168,9 +171,12 @@ def build_list_by_gallery_application_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -183,42 +189,38 @@ def build_list_by_gallery_application_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationVersionsOperations(object): - """GalleryApplicationVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -226,17 +228,20 @@ def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -250,11 +255,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -289,9 +296,9 @@ def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -325,17 +332,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -344,20 +354,27 @@ def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -379,7 +396,7 @@ def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -400,13 +417,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -418,11 +438,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -451,13 +473,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -468,11 +493,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -523,22 +550,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -548,8 +580,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -569,7 +607,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationVersionList"]: + ) -> Iterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -587,13 +625,16 @@ def list_by_gallery_application( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -604,9 +645,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -617,9 +660,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_applications_operations.py index d4b5557403f5..4f7414d84166 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplication] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,9 +83,12 @@ def build_get_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,18 +101,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -120,9 +122,12 @@ def build_delete_request_initial( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -157,9 +160,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications") # pylint: disable=line-too-long path_format_arguments = { @@ -171,59 +177,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationsOperations(object): - """GalleryApplicationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -236,11 +241,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -274,9 +281,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -305,17 +312,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -323,20 +333,27 @@ def begin_create_or_update( 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('GalleryApplication', 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( @@ -356,7 +373,7 @@ def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -372,13 +389,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -388,11 +408,13 @@ def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -420,13 +442,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -436,11 +461,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -486,21 +513,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -510,8 +542,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -530,7 +568,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationList"]: + ) -> Iterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -545,13 +583,16 @@ def list_by_gallery( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -561,9 +602,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -573,9 +616,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_image_versions_operations.py index 39af3165db03..928b41ad67c3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -87,9 +88,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -103,20 +107,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -129,9 +131,12 @@ def build_delete_request_initial( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -145,18 +150,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -168,9 +171,12 @@ def build_list_by_gallery_image_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -183,42 +189,38 @@ def build_list_by_gallery_image_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImageVersionsOperations(object): - """GalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -226,17 +228,20 @@ def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -250,11 +255,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -289,9 +296,9 @@ def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Create or update a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -324,17 +331,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -343,20 +353,27 @@ def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -378,7 +395,7 @@ def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -398,13 +415,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -416,11 +436,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -449,13 +471,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -466,11 +491,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -520,22 +547,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -545,8 +577,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -566,7 +604,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageVersionList"]: + ) -> Iterable[_models.GalleryImageVersionList]: """List gallery Image Versions in a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -584,13 +622,16 @@ def list_by_gallery_image( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -601,9 +642,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -614,9 +657,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_images_operations.py index b12c6efcaa80..30bd26d3ce9c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImage] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,9 +83,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,18 +101,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -120,9 +122,12 @@ def build_delete_request_initial( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -157,9 +160,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images") # pylint: disable=line-too-long path_format_arguments = { @@ -171,59 +177,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImagesOperations(object): - """GalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -236,11 +241,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -274,9 +281,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Create or update a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -303,17 +310,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -321,20 +331,27 @@ def begin_create_or_update( 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('GalleryImage', 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( @@ -354,7 +371,7 @@ def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -369,13 +386,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -385,11 +405,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -417,13 +439,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -433,11 +458,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -483,21 +510,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -507,8 +539,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -527,7 +565,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageList"]: + ) -> Iterable[_models.GalleryImageList]: """List gallery Image Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -540,13 +578,16 @@ def list_by_gallery( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -556,9 +597,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -568,9 +611,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_images_operations.py index 93e72aee74da..bd517794599b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -155,9 +157,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +174,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -192,9 +195,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -205,18 +211,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +229,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -237,58 +244,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -300,11 +306,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -334,9 +342,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -357,37 +365,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -404,17 +422,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -426,11 +447,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -460,9 +483,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -483,37 +506,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -532,13 +565,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -547,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,20 +631,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -616,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -637,7 +686,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -651,13 +700,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -667,11 +719,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -707,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -722,9 +779,11 @@ def prepare_request(next_link=None): 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: @@ -733,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -772,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -781,13 +842,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -805,9 +871,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_log_analytics_operations.py index 10c813c3c07d..f75ec7bad183 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_operations.py index e2665e85a29b..c04612c19d06 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_proximity_placement_groups_operations.py index 71cca9b56409..a1abcda2f012 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -185,9 +188,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -197,18 +203,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -218,9 +222,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -231,51 +238,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -289,14 +292,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2019_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -308,11 +314,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -342,9 +350,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -358,14 +366,17 @@ def update( :rtype: ~azure.mgmt.compute.v2019_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -377,11 +388,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -420,13 +433,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -435,11 +451,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -462,7 +480,7 @@ def get( resource_group_name: str, proximity_placement_group_name: str, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -474,13 +492,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -489,11 +510,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -518,7 +541,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -528,13 +551,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -542,9 +568,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -552,9 +580,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -592,7 +622,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -604,13 +634,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -619,9 +652,11 @@ def prepare_request(next_link=None): 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: @@ -630,9 +665,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_snapshots_operations.py index b1f483b4a14b..ae89183410ac 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_usage_operations.py index a85933eba15f..f0763e13aef9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_extension_images_operations.py index d1cc7019a024..0735af570275 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_extensions_operations.py index 22ba8ebcf6da..1d81a49f0813 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,8 +129,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -141,13 +144,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -161,9 +163,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -176,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -202,9 +205,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -216,61 +222,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -283,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -318,9 +325,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -347,17 +354,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -365,20 +375,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -396,17 +413,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -419,11 +439,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,9 +472,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -479,17 +501,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -497,20 +522,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -530,13 +562,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -546,11 +581,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,21 +632,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -619,8 +661,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -641,7 +689,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -657,13 +705,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -674,11 +725,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -706,7 +759,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -720,13 +773,16 @@ def list( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -736,11 +792,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_images_operations.py index 2ab52b5cd113..1e6ff2d4cfe1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_run_commands_operations.py index 041f25fd2610..e6a579e5d023 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_run_commands_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -44,18 +48,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -66,9 +68,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -80,49 +85,45 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -134,13 +135,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -149,9 +153,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -160,9 +166,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -201,7 +209,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -213,13 +221,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -228,11 +239,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_set_extensions_operations.py index 7e18ecbc389e..0830e13ae3b8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,8 +83,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -96,13 +98,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -116,9 +117,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +135,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -155,9 +157,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -169,59 +174,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -234,11 +238,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -269,9 +275,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -299,17 +305,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -317,20 +326,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -350,13 +366,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -366,11 +385,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -415,21 +436,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -439,8 +465,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -461,7 +493,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -477,13 +509,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -494,11 +529,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -525,7 +562,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -539,13 +576,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -555,9 +595,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_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,9 +609,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 70b907807209..1b8c5b922c63 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,8 +34,9 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -46,13 +48,12 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -63,8 +64,9 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -76,13 +78,12 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -93,8 +94,9 @@ def build_start_extension_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -106,13 +108,12 @@ def build_start_extension_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -123,9 +124,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -137,42 +141,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -180,13 +180,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -195,11 +198,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,20 +246,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -264,8 +274,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -284,13 +300,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -299,11 +318,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,20 +368,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -370,8 +396,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -390,13 +422,16 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -405,11 +440,13 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -453,20 +490,25 @@ def begin_start_extension_upgrade( # pylint: disable=inconsistent-return-statem :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_extension_upgrade_initial( + raw_result = self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -476,8 +518,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -496,7 +544,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -508,13 +556,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2019_03_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -523,11 +574,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_set_vms_operations.py index 101e545a6361..cc7dbca8e110 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,13 +35,15 @@ def build_reimage_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -54,19 +56,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,8 +80,9 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -94,13 +95,12 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -112,8 +112,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -126,13 +127,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -143,14 +143,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -163,20 +166,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -190,8 +191,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -204,13 +206,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -224,9 +225,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -239,20 +243,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -264,9 +266,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -279,18 +284,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -305,9 +308,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -319,24 +325,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -350,8 +354,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -364,15 +369,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -384,8 +388,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -398,13 +403,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -416,8 +420,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -430,13 +435,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -448,8 +452,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -462,13 +467,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -480,8 +484,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -494,13 +499,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -511,14 +515,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -531,63 +538,62 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -603,11 +609,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -630,7 +638,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -657,17 +665,20 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -675,6 +686,8 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -684,8 +697,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,13 +724,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -721,11 +743,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -771,21 +795,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -795,8 +824,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -816,13 +851,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -832,11 +870,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -883,21 +923,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -907,8 +952,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -926,17 +977,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -949,11 +1003,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -984,9 +1040,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1012,17 +1068,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1030,20 +1089,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1063,13 +1129,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1079,11 +1148,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1128,21 +1199,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1152,8 +1228,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1174,7 +1256,7 @@ def get( instance_id: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1183,21 +1265,24 @@ def get( :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. :type instance_id: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachineScaleSetVM, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1208,11 +1293,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1240,7 +1327,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1254,13 +1341,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1270,11 +1360,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1304,7 +1396,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1328,13 +1420,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1347,9 +1442,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1362,9 +1459,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1405,13 +1504,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1422,11 +1524,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1478,22 +1582,27 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1503,8 +1612,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1524,13 +1639,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1540,11 +1658,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1589,21 +1709,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1613,8 +1738,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1634,13 +1765,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1650,11 +1784,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1699,21 +1835,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1723,8 +1864,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1744,13 +1891,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1760,11 +1910,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1810,21 +1962,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1834,8 +1991,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1855,13 +2018,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1871,11 +2037,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1920,21 +2088,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1944,8 +2117,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1963,18 +2142,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1987,11 +2169,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2020,11 +2204,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2035,7 +2219,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2019_03_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2051,16 +2235,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2068,20 +2255,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_sets_operations.py index 31fd97256f75..05f89a4ec2f4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,18 +172,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -188,13 +191,15 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -206,19 +211,17 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -230,13 +233,15 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -248,19 +253,17 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -273,9 +276,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -287,18 +293,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -308,9 +312,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -321,18 +328,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -341,9 +346,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -353,18 +361,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -375,9 +381,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -389,18 +398,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -411,9 +418,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -425,18 +435,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -446,14 +454,16 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -465,21 +475,19 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -491,13 +499,15 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -509,19 +519,17 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -533,13 +541,15 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -551,19 +561,17 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -575,13 +583,15 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -593,19 +603,17 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -617,13 +625,15 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -635,19 +645,17 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -659,13 +667,15 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -677,19 +687,17 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -701,13 +709,15 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -719,19 +729,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -743,13 +751,15 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -761,19 +771,17 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -788,9 +796,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( platform_update_domain: int, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -802,19 +813,17 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -824,13 +833,15 @@ def build_convert_to_single_placement_group_request( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VMScaleSetConvertToSinglePlacementGroupInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup") # pylint: disable=line-too-long path_format_arguments = { @@ -842,61 +853,60 @@ def build_convert_to_single_placement_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -908,11 +918,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -942,9 +954,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -967,37 +979,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1014,17 +1036,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -1036,11 +1061,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1066,9 +1093,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1091,37 +1118,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1140,13 +1177,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1155,11 +1195,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1201,20 +1243,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1224,8 +1271,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1244,7 +1297,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1256,13 +1309,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1271,11 +1327,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1300,17 +1358,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1325,11 +1386,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1351,7 +1414,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1378,23 +1441,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1404,8 +1472,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1422,17 +1496,20 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1444,11 +1521,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1470,7 +1549,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -1494,23 +1573,28 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1520,8 +1604,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1540,7 +1630,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1552,13 +1642,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1567,11 +1660,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1597,7 +1692,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1609,13 +1704,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1624,9 +1722,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1635,9 +1735,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1674,7 +1776,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1686,13 +1788,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1700,9 +1805,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1710,9 +1817,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1751,7 +1860,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1766,13 +1875,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1782,9 +1894,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1794,9 +1908,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1835,7 +1951,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1849,13 +1965,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1865,9 +1984,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1877,9 +1998,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1917,17 +2040,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1943,11 +2069,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1970,7 +2098,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -2001,17 +2129,20 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -2019,6 +2150,8 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2028,8 +2161,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2046,17 +2185,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2071,11 +2213,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2097,7 +2241,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2122,23 +2266,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2148,8 +2297,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2166,17 +2321,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2191,11 +2349,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2217,7 +2377,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2242,23 +2402,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2268,8 +2433,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2286,17 +2457,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2311,11 +2485,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2337,7 +2513,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2363,23 +2539,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2389,8 +2570,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2407,17 +2594,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2432,11 +2622,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2458,7 +2650,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2486,23 +2678,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2512,8 +2709,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2530,17 +2733,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2552,11 +2758,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2578,7 +2786,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2602,23 +2810,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2628,8 +2841,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2646,17 +2865,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -2671,11 +2893,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2697,7 +2921,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -2723,23 +2947,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2749,8 +2978,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2767,17 +3002,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2792,11 +3030,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2818,7 +3058,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2844,23 +3084,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2870,8 +3115,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2891,7 +3142,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2907,13 +3158,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2019_03_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2923,11 +3177,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2953,7 +3209,7 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to true for a existing virtual machine scale set. @@ -2970,14 +3226,17 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st :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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -2989,11 +3248,13 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_sizes_operations.py index ed5d045093d6..422d58a5b15d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -99,13 +99,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machines_operations.py index 9b1b22d8f853..33a604d5ba1a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_03_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -201,8 +205,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -214,13 +219,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -233,9 +237,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -247,20 +254,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -271,9 +276,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -285,18 +293,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -307,8 +313,9 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -320,13 +327,12 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -337,8 +343,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -350,13 +357,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -367,8 +373,9 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -380,13 +387,12 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -396,9 +402,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -409,18 +418,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -429,9 +436,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -441,18 +451,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -463,9 +471,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -477,18 +488,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -501,8 +510,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -514,15 +524,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -533,8 +542,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -546,13 +556,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -563,8 +572,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -576,13 +586,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -593,8 +602,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -606,13 +616,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -622,13 +631,15 @@ def build_reimage_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -640,19 +651,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -665,8 +674,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -678,13 +688,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -694,14 +703,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -713,53 +725,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2019_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2019_03_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -771,13 +779,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -786,9 +797,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -797,9 +810,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -836,17 +851,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -858,11 +876,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -890,9 +910,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -916,37 +936,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -963,17 +993,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -985,11 +1018,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1019,9 +1054,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1043,37 +1078,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1090,17 +1135,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1112,11 +1160,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1146,9 +1196,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1170,37 +1220,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1219,13 +1279,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1234,11 +1297,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1280,20 +1345,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1303,8 +1373,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1324,28 +1400,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1355,11 +1434,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1386,7 +1467,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1398,13 +1479,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2019_03_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1413,11 +1497,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1444,13 +1530,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1459,11 +1548,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1506,20 +1597,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1529,8 +1625,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1549,13 +1651,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -1564,11 +1669,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1611,20 +1718,25 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1634,8 +1746,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1666,13 +1784,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1681,11 +1802,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1707,7 +1830,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1720,13 +1843,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1735,9 +1861,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1746,9 +1874,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1785,7 +1915,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1796,13 +1926,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1810,9 +1943,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1820,9 +1955,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1861,7 +1998,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1876,13 +2013,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1892,9 +2032,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1904,9 +2046,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1946,13 +2090,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1962,11 +2109,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2014,21 +2163,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2038,8 +2192,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2058,13 +2218,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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', "2019-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2073,11 +2236,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2119,20 +2284,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2142,8 +2312,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2162,13 +2338,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2177,11 +2356,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2223,20 +2404,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2246,8 +2432,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2266,13 +2458,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2281,11 +2476,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2327,20 +2524,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2350,8 +2552,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2368,17 +2576,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -2393,11 +2604,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2419,7 +2632,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -2443,23 +2656,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -2469,8 +2687,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2489,13 +2713,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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 {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2504,11 +2731,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2550,20 +2779,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2573,8 +2807,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2591,18 +2831,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2614,11 +2857,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2646,11 +2891,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2659,7 +2904,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2019_03_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2675,36 +2920,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_03_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_compute_management_client.py index e50845b096bb..e4afbb2fb455 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_compute_management_client.py @@ -53,7 +53,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_skus = ResourceSkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/_compute_management_client.py index 386767064d4c..af2308ec0f08 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/_compute_management_client.py @@ -53,7 +53,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_skus = ResourceSkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/__init__.py index 46d684b6a0cc..9aa451b77759 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/__init__.py @@ -8,6 +8,11 @@ from ._resource_skus_operations import ResourceSkusOperations +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__ = [ 'ResourceSkusOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/_resource_skus_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/_resource_skus_operations.py index 645fd985cee5..f325662c8b24 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/_resource_skus_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/aio/operations/_resource_skus_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ResourceSkusOperations: - """ResourceSkusOperations async operations. - - You 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.compute.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.compute.v2019_04_01.aio.ComputeManagementClient`'s + :attr:`resource_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, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceSkusResult"]: + ) -> AsyncIterable[_models.ResourceSkusResult]: """Gets the list of Microsoft.Compute SKUs available for your Subscription. :param filter: The filter to apply on the operation. Only **location** filter is supported @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_04_01.models.ResourceSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/__init__.py index 186f1cb989d3..0f5a98740340 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/__init__.py @@ -22,7 +22,9 @@ ResourceSkuRestrictionsReasonCode, ResourceSkuRestrictionsType, ) - +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__ = [ 'ResourceSku', 'ResourceSkuCapabilities', @@ -37,3 +39,5 @@ 'ResourceSkuRestrictionsReasonCode', 'ResourceSkuRestrictionsType', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_compute_management_client_enums.py index d85caa49fe4f..1f65e79f3a25 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ @@ -19,14 +18,14 @@ class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, MANUAL = "Manual" NONE = "None" -class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for restriction. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ResourceSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of restrictions. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_models_py3.py index c02cbe4bb5a4..eb9c390e6763 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_models_py3.py @@ -6,10 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional +from typing import List, Optional, TYPE_CHECKING import msrest.serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + class ResourceSku(msrest.serialization.Model): """Describes an available Compute SKU. @@ -145,7 +149,7 @@ class ResourceSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default: The default capacity. :vartype default: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "Manual", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2019_04_01.models.ResourceSkuCapacityScaleType """ @@ -288,14 +292,14 @@ class ResourceSkuRestrictions(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of restrictions. Possible values include: "Location", "Zone". + :ivar type: The type of restrictions. Known values are: "Location", "Zone". :vartype type: str or ~azure.mgmt.compute.v2019_04_01.models.ResourceSkuRestrictionsType :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 restriction_info: The information about the restriction where the SKU cannot be used. :vartype restriction_info: ~azure.mgmt.compute.v2019_04_01.models.ResourceSkuRestrictionInfo - :ivar reason_code: The reason for restriction. Possible values include: "QuotaId", + :ivar reason_code: The reason for restriction. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.compute.v2019_04_01.models.ResourceSkuRestrictionsReasonCode @@ -352,7 +356,7 @@ class ResourceSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["ResourceSku"], + value: List["_models.ResourceSku"], next_link: Optional[str] = None, **kwargs ): diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/__init__.py index 46d684b6a0cc..9aa451b77759 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/__init__.py @@ -8,6 +8,11 @@ from ._resource_skus_operations import ResourceSkusOperations +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__ = [ 'ResourceSkusOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/_resource_skus_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/_resource_skus_operations.py index bcd1bd207d3e..597c0e6ac7e7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/_resource_skus_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_04_01/operations/_resource_skus_operations.py @@ -16,6 +16,7 @@ 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 @@ -32,9 +33,12 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/skus") path_format_arguments = { @@ -44,51 +48,47 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 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, + params=_params, + headers=_headers, **kwargs ) -class ResourceSkusOperations(object): - """ResourceSkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2019_04_01.ComputeManagementClient`'s + :attr:`resource_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, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ResourceSkusResult"]: + ) -> Iterable[_models.ResourceSkusResult]: """Gets the list of Microsoft.Compute SKUs available for your Subscription. :param filter: The filter to apply on the operation. Only **location** filter is supported @@ -99,13 +99,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_04_01.models.ResourceSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_compute_management_client.py index d0b13ec11d7d..42f1ddbb0083 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_compute_management_client.py @@ -127,33 +127,87 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/_compute_management_client.py index b7fd5fb17825..cd3b5edebc7e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/_compute_management_client.py @@ -129,33 +129,87 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/__init__.py index 84aa626c09ed..29856efddb78 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/__init__.py @@ -34,6 +34,9 @@ from ._gallery_application_versions_operations import GalleryApplicationVersionsOperations from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations +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', 'AvailabilitySetsOperations', @@ -63,3 +66,5 @@ 'GalleryApplicationVersionsOperations', 'VirtualMachineRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_availability_sets_operations.py index c080ba725610..efe1abe782bb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_dedicated_host_groups_operations.py index a0aa46c4621d..08b5bf450b80 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_dedicated_host_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostGroupsOperations: - """DedicatedHostGroupsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -137,14 +141,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -156,11 +163,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -199,13 +208,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,11 +226,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,7 +255,7 @@ async def get( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -253,13 +267,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -268,11 +285,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -298,7 +317,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -311,13 +330,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -326,9 +348,11 @@ def prepare_request(next_link=None): 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: @@ -337,9 +361,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +402,7 @@ async def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -387,13 +413,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,9 +430,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -411,9 +442,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_dedicated_hosts_operations.py index 718ce3dcd209..72745f0eccc7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostsOperations: - """DedicatedHostsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('DedicatedHost', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -267,17 +286,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -285,20 +307,27 @@ async def begin_update( 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('DedicatedHost', 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( @@ -318,13 +347,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -334,11 +366,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,21 +417,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -407,8 +446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -429,7 +474,7 @@ async def get( host_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -438,21 +483,24 @@ async def get( :type host_group_name: str :param host_name: The name of the dedicated host. :type host_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedHost, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -463,11 +511,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -494,7 +544,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostListResult"]: + ) -> AsyncIterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -509,13 +559,16 @@ def list_by_host_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -525,9 +578,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -537,9 +592,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_disk_encryption_sets_operations.py index 09dacdf5be75..fd001b24dce0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskEncryptionSetsOperations: - """DiskEncryptionSetsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -238,9 +257,9 @@ async def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -266,37 +285,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -315,7 +344,7 @@ async def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -329,13 +358,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -344,11 +376,13 @@ async def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -375,13 +409,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -390,11 +427,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,20 +477,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -461,8 +505,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -480,7 +530,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -492,13 +542,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -507,9 +560,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -518,9 +573,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -557,7 +614,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -567,13 +624,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -581,9 +641,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -591,9 +653,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_disks_operations.py index 116e3e876457..9136915e6fff 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_galleries_operations.py index 6c40aaff74f7..56956ebf78de 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleriesOperations: - """GalleriesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'GalleryUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -234,9 +253,9 @@ async def begin_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -259,37 +278,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -308,7 +337,7 @@ async def get( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -320,13 +349,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -335,11 +367,13 @@ async def get( gallery_name=gallery_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,13 +400,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -381,11 +418,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -427,20 +466,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -450,8 +494,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -469,7 +519,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -480,13 +530,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -495,9 +548,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -506,9 +561,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -545,7 +602,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -554,13 +611,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -568,9 +628,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -578,9 +640,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_application_versions_operations.py index 612edce119fa..9d16d4c3797d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationVersionsOperations: - """GalleryApplicationVersionsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -152,17 +156,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -171,20 +178,27 @@ async def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -203,17 +217,20 @@ async def _update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersionUpdate') @@ -227,11 +244,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -259,9 +278,9 @@ async def begin_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -295,17 +314,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -314,20 +336,27 @@ async def begin_update( 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('GalleryApplicationVersion', 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( @@ -349,7 +378,7 @@ async def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -370,13 +399,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -388,11 +420,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -421,13 +455,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -438,11 +475,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -493,22 +532,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -518,8 +562,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -539,7 +589,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationVersionList"]: + ) -> AsyncIterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -557,13 +607,16 @@ def list_by_gallery_application( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -574,9 +627,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -587,9 +642,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_applications_operations.py index 162131f172de..bc4c90d43279 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationsOperations: - """GalleryApplicationsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -144,17 +148,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -162,20 +169,27 @@ async def begin_create_or_update( 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('GalleryApplication', 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( @@ -193,17 +207,20 @@ async def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplicationUpdate') @@ -216,11 +233,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -277,17 +296,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -295,20 +317,27 @@ async def begin_update( 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('GalleryApplication', 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( @@ -328,7 +357,7 @@ async def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -344,13 +373,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -360,11 +392,13 @@ async def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,13 +426,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -408,11 +445,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,21 +497,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -482,8 +526,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -502,7 +552,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationList"]: + ) -> AsyncIterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -517,13 +567,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -533,9 +586,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -545,9 +600,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_image_versions_operations.py index 9e707c41bf99..fe82c1e1401a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImageVersionsOperations: - """GalleryImageVersionsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Create or update a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -151,17 +155,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -170,20 +177,27 @@ async def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -202,17 +216,20 @@ async def _update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersionUpdate') @@ -226,11 +243,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -258,9 +277,9 @@ async def begin_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Update a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -293,17 +312,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -312,20 +334,27 @@ async def begin_update( 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('GalleryImageVersion', 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( @@ -347,7 +376,7 @@ async def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -367,13 +396,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -385,11 +417,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -418,13 +452,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -435,11 +472,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -489,22 +528,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -514,8 +558,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -535,7 +585,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageVersionList"]: + ) -> AsyncIterable[_models.GalleryImageVersionList]: """List gallery Image Versions in a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -553,13 +603,16 @@ def list_by_gallery_image( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +623,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +638,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_images_operations.py index 0068844b61b3..c2bee08b37a4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImagesOperations: - """GalleryImagesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Create or update a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -160,20 +167,27 @@ async def begin_create_or_update( 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('GalleryImage', 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( @@ -191,17 +205,20 @@ async def _update_initial( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImageUpdate') @@ -214,11 +231,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -245,9 +264,9 @@ async def begin_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Update a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -274,17 +293,20 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -292,20 +314,27 @@ async def begin_update( 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('GalleryImage', 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( @@ -325,7 +354,7 @@ async def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -340,13 +369,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -356,11 +388,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -388,13 +422,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -404,11 +441,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -454,21 +493,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -478,8 +522,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -498,7 +548,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageList"]: + ) -> AsyncIterable[_models.GalleryImageList]: """List gallery Image Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -512,13 +562,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -528,9 +581,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -540,9 +595,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_images_operations.py index c5f76f0af051..825dd52e4bf6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_log_analytics_operations.py index ff7c05ad5ba5..b759024442aa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_operations.py index 0036c83a9b9a..47c360689752 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_proximity_placement_groups_operations.py index 2091b13e7dd6..b03ca41cf7c2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,7 +254,7 @@ async def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -255,13 +269,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -271,11 +288,13 @@ async def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -300,7 +319,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -310,13 +329,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -324,9 +346,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -334,9 +358,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -374,7 +400,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -386,13 +412,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,9 +430,11 @@ def prepare_request(next_link=None): 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: @@ -412,9 +443,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_snapshots_operations.py index 4acb049cf253..0f8aaab664f5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_usage_operations.py index 2b94a90e0438..08d396dad1da 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_extension_images_operations.py index 56f3464de657..715f01ba7ea4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_extensions_operations.py index bd0643662b92..5cef039661b9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_images_operations.py index d7d1113d27f5..5535fa7f0888 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_run_commands_operations.py index f76885479889..7b99b8905a20 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -15,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 @@ -24,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,7 +135,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -141,13 +147,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -156,11 +165,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index d554d2e4a221..91d30f0946a4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -189,17 +203,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -212,11 +229,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -276,17 +295,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -294,20 +316,27 @@ async def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -327,13 +356,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -343,11 +375,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,21 +426,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -416,8 +455,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -438,7 +483,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -516,13 +566,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -532,9 +585,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -544,9 +599,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 2448b0b173a8..d760d090494d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,13 +292,16 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu vm_scale_set_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -276,11 +310,13 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,20 +360,25 @@ async def begin_start_extension_upgrade( # pylint: disable=inconsistent-return- :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_extension_upgrade_initial( + raw_result = await self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -347,8 +388,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -367,7 +414,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -379,13 +426,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -394,11 +444,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py index 4df90df55e8e..3540235428eb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMExtensionsOperations: - """VirtualMachineScaleSetVMExtensionsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -51,17 +50,20 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -111,9 +115,9 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -141,17 +145,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -160,20 +167,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -192,17 +206,20 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -216,11 +233,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -248,9 +267,9 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -279,17 +298,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -298,20 +320,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -332,13 +361,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -349,11 +381,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,22 +435,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -426,8 +465,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -449,7 +494,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -467,13 +512,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -485,11 +533,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -518,7 +568,7 @@ async def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -534,13 +584,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -551,11 +604,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index 69cf4ca73d18..337224148dc9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -78,11 +80,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -132,17 +136,20 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -150,6 +157,8 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,13 +195,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -196,11 +214,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,21 +266,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -270,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -291,13 +322,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -307,11 +341,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,21 +394,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -382,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -401,17 +448,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -424,11 +474,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,9 +511,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -487,17 +539,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -505,20 +560,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -538,13 +600,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -554,11 +619,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -603,21 +670,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -627,8 +699,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -649,7 +727,7 @@ async def get( instance_id: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -658,21 +736,24 @@ async def get( :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. :type instance_id: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachineScaleSetVM, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -683,11 +764,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -715,7 +798,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -729,13 +812,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -745,11 +831,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -779,7 +867,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -803,13 +891,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -822,9 +913,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -837,9 +930,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -880,13 +975,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -897,11 +995,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -953,22 +1053,27 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -978,8 +1083,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -999,13 +1110,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1015,11 +1129,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1064,21 +1180,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1088,8 +1209,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1109,13 +1236,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1125,11 +1255,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1174,21 +1306,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1198,8 +1335,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1219,13 +1362,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1235,11 +1381,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1285,21 +1433,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1309,8 +1462,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1330,13 +1489,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1346,11 +1508,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1396,21 +1560,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1420,8 +1589,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1439,18 +1614,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1463,11 +1641,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1496,11 +1676,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1511,7 +1691,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2019_07_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1528,16 +1708,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1545,20 +1728,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_sets_operations.py index b49aff89230f..d3b2e501c58d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -231,9 +250,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -409,7 +454,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -421,13 +466,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -436,11 +484,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -465,17 +515,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -490,11 +543,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -516,7 +571,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -543,23 +598,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -569,8 +629,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -587,17 +653,20 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -609,11 +678,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,7 +706,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -659,23 +730,28 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +761,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +787,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -717,13 +799,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -732,11 +817,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -762,7 +849,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -774,13 +861,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -789,9 +879,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -800,9 +892,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -839,7 +933,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -851,13 +945,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -865,9 +962,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -875,9 +974,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +1017,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -931,13 +1032,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -947,9 +1051,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -959,9 +1065,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1000,7 +1108,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1014,13 +1122,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1030,9 +1141,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1042,9 +1155,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1082,17 +1197,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1108,11 +1226,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1135,7 +1255,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1166,17 +1286,20 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -1184,6 +1307,8 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1193,8 +1318,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1211,17 +1342,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1236,11 +1370,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1262,7 +1398,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1287,23 +1423,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1313,8 +1454,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1331,17 +1478,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1356,11 +1506,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1382,7 +1534,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1407,23 +1559,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1433,8 +1590,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1451,17 +1614,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1476,11 +1642,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1502,7 +1670,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1528,23 +1696,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1554,8 +1727,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1572,17 +1751,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1597,11 +1779,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1623,7 +1807,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1651,23 +1835,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1677,8 +1866,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1695,17 +1890,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1717,11 +1915,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1743,7 +1943,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1767,23 +1967,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1793,8 +1998,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1811,17 +2022,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -1836,11 +2050,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1862,7 +2078,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -1888,23 +2104,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1914,8 +2135,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1932,17 +2159,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1957,11 +2187,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1983,7 +2215,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2009,23 +2241,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2035,8 +2272,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2056,7 +2299,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2072,13 +2315,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2019_07_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2088,11 +2334,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2118,7 +2366,7 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to true for a existing virtual machine scale set. @@ -2135,14 +2383,17 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret :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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] _json = self._serialize.body(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -2154,11 +2405,13 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_sizes_operations.py index 6f1502045fdb..303427276816 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machines_operations.py index efe469c293a6..a090d87590c7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -338,37 +364,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -385,17 +421,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -407,11 +446,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -441,9 +482,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -466,37 +507,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -515,13 +566,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -530,11 +584,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -576,20 +632,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -599,8 +660,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -620,28 +687,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -651,11 +721,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -682,7 +754,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -694,13 +766,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -709,11 +784,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -740,13 +817,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -755,11 +835,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -806,20 +888,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -829,8 +916,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -849,13 +942,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -864,11 +960,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -911,20 +1009,25 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -934,8 +1037,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -971,13 +1080,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -986,11 +1098,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1012,7 +1126,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1025,13 +1139,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1040,9 +1157,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1051,9 +1170,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1091,7 +1212,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1105,13 +1226,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1120,9 +1244,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1131,9 +1257,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1172,7 +1300,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1187,13 +1315,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1203,9 +1334,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1215,9 +1348,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1257,13 +1392,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1273,11 +1411,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1325,21 +1465,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1349,8 +1494,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1369,13 +1520,16 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -1384,11 +1538,13 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1430,20 +1586,25 @@ async def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reapply_initial( + raw_result = await self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1453,8 +1614,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1473,13 +1640,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1488,11 +1658,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1534,20 +1706,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1557,8 +1734,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1577,13 +1760,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1592,11 +1778,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1638,20 +1826,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1661,8 +1854,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1681,13 +1880,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1696,11 +1898,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1742,20 +1946,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1765,8 +1974,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1783,17 +1998,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -1808,11 +2026,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1834,7 +2054,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -1858,23 +2078,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -1884,8 +2109,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1904,13 +2135,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1919,11 +2153,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1966,20 +2202,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1989,8 +2230,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2007,18 +2254,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2030,11 +2280,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2062,11 +2314,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2075,7 +2327,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2019_07_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2092,36 +2344,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_07_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/__init__.py index 9cfeac2f5f6b..451cb5544602 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/__init__.py @@ -284,7 +284,9 @@ VirtualMachineScaleSetSkuScaleType, VirtualMachineSizeTypes, ) - +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__ = [ 'AccessUri', 'AdditionalCapabilities', @@ -561,3 +563,5 @@ 'VirtualMachineScaleSetSkuScaleType', 'VirtualMachineSizeTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_compute_management_client_enums.py index bd9627e561c1..3058baf58f32 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_compute_management_client_enums.py @@ -7,17 +7,16 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" WRITE = "Write" -class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the aggregated replication status based on all the regional replication status flags. """ @@ -26,7 +25,7 @@ class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, En COMPLETED = "Completed" FAILED = "Failed" -class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. """ @@ -34,7 +33,7 @@ class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CLASSIC = "Classic" ALIGNED = "Aligned" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -45,7 +44,7 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the software license type that will be applied to the VMs deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` @@ -56,13 +55,13 @@ class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" -class DiffDiskOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk option for operating system disk. """ LOCAL = "Local" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -84,7 +83,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the disk. UPLOAD = "Upload" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -97,13 +96,13 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported. """ SYSTEM_ASSIGNED = "SystemAssigned" -class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the disk. """ @@ -120,7 +119,7 @@ class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: A disk is created for upload and a write token has been issued for uploading to it. ACTIVE_UPLOAD = "ActiveUpload" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -135,7 +134,7 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: databases (for example, SQL, Oracle), and other transaction-heavy workloads. ULTRA_SSD_LRS = "UltraSSD_LRS" -class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -144,7 +143,7 @@ class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Disk is encrypted with Customer managed key at rest. ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" -class GalleryApplicationVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryApplicationVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -155,7 +154,7 @@ class GalleryApplicationVersionPropertiesProvisioningState(with_metaclass(CaseIn DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImagePropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -166,7 +165,7 @@ class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnum DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImageVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -177,7 +176,7 @@ class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensit DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -188,7 +187,7 @@ class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, DELETING = "Deleting" MIGRATING = "Migrating" -class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite' """ @@ -196,28 +195,28 @@ class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class HyperVGenerationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type associated with a resource """ V1 = "V1" V2 = "V2" -class HyperVGenerationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type """ V1 = "V1" V2 = "V2" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -226,7 +225,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -235,7 +234,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -244,7 +243,7 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ @@ -253,14 +252,14 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: Specialized image. Contains already provisioned OS Disk. SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -268,7 +267,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -277,7 +276,7 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the regional replication state. """ @@ -286,11 +285,11 @@ class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAILED = "Failed" -class ReplicationStatusTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): REPLICATION_STATUS = "ReplicationStatus" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -301,14 +300,14 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -317,7 +316,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -325,7 +324,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -336,7 +335,7 @@ class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E #: Standard zone redundant storage. STANDARD_ZRS = "Standard_ZRS" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -344,7 +343,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type to be used to store the image. This property is not updatable. """ @@ -352,7 +351,7 @@ class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_LRS = "Standard_LRS" STANDARD_ZRS = "Standard_ZRS" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. StandardSSD_LRS uses Standard SSD. Premium_LRS uses Premium SSD. UltraSSD_LRS uses Ultra disk. @@ -367,7 +366,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_SSD_LRS = "StandardSSD_LRS" ULTRA_SSD_LRS = "UltraSSD_LRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -379,7 +378,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -387,7 +386,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -396,14 +395,14 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for the Azure Spot VM/VMSS """ DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for a standalone virtual machine or the virtual machines in the scale set. :code:`
`:code:`
` 'Low' enum will be deprecated in the future, please use 'Spot' as the enum to deploy Azure Spot VM/VMSS. @@ -413,20 +412,20 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E LOW = "Low" SPOT = "Spot" -class VirtualMachineScaleSetScaleInRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "Default" OLDEST_VM = "OldestVM" NEWEST_VM = "NewestVM" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. For more information about virtual machine sizes, see `Sizes for virtual machines `_. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_models_py3.py index cc082c60f8d9..493d3a391fde 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -83,7 +85,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2019_07_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -104,7 +106,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -117,7 +119,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2019_07_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -185,8 +187,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -488,11 +490,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -550,7 +552,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -632,11 +634,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -870,8 +872,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :vartype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOption :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -911,9 +913,9 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, upload_size_bytes: Optional[int] = None, @@ -921,7 +923,7 @@ def __init__( ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :paramtype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOption :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -971,8 +973,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -983,7 +984,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1030,14 +1031,14 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, to_be_detached: Optional[bool] = None, **kwargs ): @@ -1057,8 +1058,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1069,7 +1069,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1158,7 +1158,7 @@ class DedicatedHost(Resource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1203,11 +1203,11 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1228,7 +1228,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostLicenseTypes """ @@ -1294,7 +1294,7 @@ class DedicatedHostAvailableCapacity(msrest.serialization.Model): def __init__( self, *, - allocatable_v_ms: Optional[List["DedicatedHostAllocatableVM"]] = None, + allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs ): """ @@ -1405,7 +1405,7 @@ class DedicatedHostGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHostGroup"], + value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs ): @@ -1502,8 +1502,8 @@ class DedicatedHostInstanceView(msrest.serialization.Model): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1543,7 +1543,7 @@ class DedicatedHostListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHost"], + value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs ): @@ -1580,7 +1580,7 @@ class DedicatedHostUpdate(UpdateResource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1617,7 +1617,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1633,7 +1633,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostLicenseTypes """ @@ -1665,7 +1665,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -1682,8 +1682,8 @@ def __init__( class DiffDiskSettings(msrest.serialization.Model): """Describes the parameters of ephemeral disk settings that can be specified for operating system disk. :code:`
`:code:`
` NOTE: The ephemeral disk settings can only be specified for managed disk. - :ivar option: Specifies the ephemeral disk settings for operating system disk. Possible values - include: "Local". + :ivar option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :vartype option: str or ~azure.mgmt.compute.v2019_07_01.models.DiffDiskOptions """ @@ -1694,12 +1694,12 @@ class DiffDiskSettings(msrest.serialization.Model): def __init__( self, *, - option: Optional[Union[str, "DiffDiskOptions"]] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, **kwargs ): """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. Possible - values include: "Local". + :keyword option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :paramtype option: str or ~azure.mgmt.compute.v2019_07_01.models.DiffDiskOptions """ super(DiffDiskSettings, self).__init__(**kwargs) @@ -1757,10 +1757,10 @@ class Disk(Resource): :vartype zones: list[str] :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGeneration :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1787,7 +1787,7 @@ class Disk(Resource): disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. :vartype disk_m_bps_read_write: int - :ivar disk_state: The state of the disk. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", "Reserved", "ActiveSAS", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2019_07_01.models.DiskState :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed @@ -1837,16 +1837,16 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - creation_data: Optional["CreationData"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, **kwargs ): """ @@ -1859,10 +1859,10 @@ def __init__( :paramtype sku: ~azure.mgmt.compute.v2019_07_01.models.DiskSku :keyword zones: The Logical zone list for Disk. :paramtype zones: list[str] - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGeneration :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1962,8 +1962,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - active_key: Optional["KeyVaultAndKeyReference"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + active_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -2008,7 +2008,7 @@ class DiskEncryptionSetList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskEncryptionSet"], + value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs ): @@ -2094,8 +2094,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -2133,7 +2133,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - active_key: Optional["KeyVaultAndKeyReference"] = None, + active_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -2171,8 +2171,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2215,7 +2215,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -2236,8 +2236,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS". :vartype name: str or ~azure.mgmt.compute.v2019_07_01.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -2255,11 +2255,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype name: str or ~azure.mgmt.compute.v2019_07_01.models.DiskStorageAccountTypes """ @@ -2276,7 +2276,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -2314,13 +2314,13 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, **kwargs ): """ @@ -2329,7 +2329,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :paramtype sku: ~azure.mgmt.compute.v2019_07_01.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -2370,8 +2370,8 @@ class Encryption(msrest.serialization.Model): :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :vartype disk_encryption_set_id: str - :ivar type: Required. The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey". + :ivar type: Required. The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey". :vartype type: str or ~azure.mgmt.compute.v2019_07_01.models.EncryptionType """ @@ -2387,7 +2387,7 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "EncryptionType"], + type: Union[str, "_models.EncryptionType"], disk_encryption_set_id: Optional[str] = None, **kwargs ): @@ -2395,8 +2395,8 @@ def __init__( :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :paramtype disk_encryption_set_id: str - :keyword type: Required. The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey". + :keyword type: Required. The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey". :paramtype type: str or ~azure.mgmt.compute.v2019_07_01.models.EncryptionType """ super(Encryption, self).__init__(**kwargs) @@ -2410,7 +2410,7 @@ class EncryptionSetIdentity(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is - supported. Possible values include: "SystemAssigned". + supported. Known values are: "SystemAssigned". :vartype type: str or ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetIdentityType :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a @@ -2436,12 +2436,12 @@ class EncryptionSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "DiskEncryptionSetIdentityType"]] = None, + type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, **kwargs ): """ :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned - is supported. Possible values include: "SystemAssigned". + is supported. Known values are: "SystemAssigned". :paramtype type: str or ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetIdentityType """ super(EncryptionSetIdentity, self).__init__(**kwargs) @@ -2483,7 +2483,7 @@ def __init__( self, *, enabled: bool, - encryption_settings: Optional[List["EncryptionSettingsElement"]] = None, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, encryption_settings_version: Optional[str] = None, **kwargs ): @@ -2525,8 +2525,8 @@ class EncryptionSettingsElement(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -2564,8 +2564,8 @@ class Gallery(Resource): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2019_07_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_07_01.models.GalleryPropertiesProvisioningState """ @@ -2595,7 +2595,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, **kwargs ): """ @@ -2646,8 +2646,8 @@ class GalleryApplication(Resource): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes """ @@ -2682,7 +2682,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -2704,8 +2704,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes """ @@ -2742,7 +2742,7 @@ class GalleryApplicationList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplication"], + value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs ): @@ -2778,8 +2778,8 @@ class GalleryApplicationUpdate(UpdateResource): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes """ @@ -2802,7 +2802,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -2822,8 +2822,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes """ @@ -2856,8 +2856,8 @@ class GalleryApplicationVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersionPropertiesProvisioningState :ivar replication_status: This is the replication status of the gallery Image Version. @@ -2889,7 +2889,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -2931,7 +2931,7 @@ class GalleryApplicationVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplicationVersion"], + value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs ): @@ -2968,7 +2968,7 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType """ @@ -2988,11 +2988,11 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, **kwargs ): """ @@ -3010,7 +3010,7 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType """ @@ -3046,7 +3046,7 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType :ivar source: Required. The source image from which the Image Version is going to be created. :vartype source: ~azure.mgmt.compute.v2019_07_01.models.UserArtifactSource @@ -3076,13 +3076,13 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil def __init__( self, *, - source: "UserArtifactSource", - target_regions: Optional[List["TargetRegion"]] = None, + source: "_models.UserArtifactSource", + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - manage_actions: Optional["UserArtifactManage"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + manage_actions: Optional["_models.UserArtifactManage"] = None, enable_health_check: Optional[bool] = None, **kwargs ): @@ -3101,7 +3101,7 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType :keyword source: Required. The source image from which the Image Version is going to be @@ -3128,8 +3128,8 @@ class GalleryApplicationVersionUpdate(UpdateResource): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersionPropertiesProvisioningState :ivar replication_status: This is the replication status of the gallery Image Version. @@ -3152,7 +3152,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -3188,7 +3188,7 @@ class GalleryArtifactSource(msrest.serialization.Model): def __init__( self, *, - managed_image: "ManagedArtifact", + managed_image: "_models.ManagedArtifact", **kwargs ): """ @@ -3234,7 +3234,7 @@ class GalleryDiskImage(msrest.serialization.Model): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2019_07_01.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource @@ -3253,13 +3253,13 @@ class GalleryDiskImage(msrest.serialization.Model): def __init__( self, *, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2019_07_01.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource @@ -3280,7 +3280,7 @@ class GalleryDataDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2019_07_01.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource @@ -3306,13 +3306,13 @@ def __init__( self, *, lun: int, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2019_07_01.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource @@ -3381,15 +3381,15 @@ class GalleryImage(Resource): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemStateTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGeneration :ivar end_of_life_date: The end of life date of the gallery Image Definition. This property can be used for decommissioning purposes. This property is updatable. @@ -3404,8 +3404,8 @@ class GalleryImage(Resource): :ivar purchase_plan: Describes the gallery Image Definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2019_07_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_07_01.models.GalleryImagePropertiesProvisioningState """ @@ -3448,14 +3448,14 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, **kwargs ): """ @@ -3474,15 +3474,15 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemStateTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGeneration :keyword end_of_life_date: The end of life date of the gallery Image Definition. This property can be used for decommissioning purposes. This property is updatable. @@ -3585,7 +3585,7 @@ class GalleryImageList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImage"], + value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs ): @@ -3619,15 +3619,15 @@ class GalleryImageUpdate(UpdateResource): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemStateTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGeneration :ivar end_of_life_date: The end of life date of the gallery Image Definition. This property can be used for decommissioning purposes. This property is updatable. @@ -3642,8 +3642,8 @@ class GalleryImageUpdate(UpdateResource): :ivar purchase_plan: Describes the gallery Image Definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2019_07_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_07_01.models.GalleryImagePropertiesProvisioningState """ @@ -3677,14 +3677,14 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, **kwargs ): """ @@ -3701,15 +3701,15 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemStateTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGeneration :keyword end_of_life_date: The end of life date of the gallery Image Definition. This property can be used for decommissioning purposes. This property is updatable. @@ -3761,8 +3761,8 @@ class GalleryImageVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery Image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionPropertiesProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -3798,8 +3798,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["GalleryImageVersionStorageProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -3845,7 +3845,7 @@ class GalleryImageVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImageVersion"], + value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs ): @@ -3882,7 +3882,7 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType """ @@ -3902,11 +3902,11 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, **kwargs ): """ @@ -3924,7 +3924,7 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType """ @@ -3951,9 +3951,9 @@ class GalleryImageVersionStorageProfile(msrest.serialization.Model): def __init__( self, *, - source: Optional["GalleryArtifactVersionSource"] = None, - os_disk_image: Optional["GalleryOSDiskImage"] = None, - data_disk_images: Optional[List["GalleryDataDiskImage"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, + os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, + data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, **kwargs ): """ @@ -3980,8 +3980,8 @@ class GalleryImageVersionUpdate(UpdateResource): :ivar publishing_profile: The publishing profile of a gallery Image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionPropertiesProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -4008,8 +4008,8 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["GalleryImageVersionStorageProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -4053,7 +4053,7 @@ class GalleryList(msrest.serialization.Model): def __init__( self, *, - value: List["Gallery"], + value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs ): @@ -4077,7 +4077,7 @@ class GalleryOSDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2019_07_01.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource @@ -4096,13 +4096,13 @@ class GalleryOSDiskImage(GalleryDiskImage): def __init__( self, *, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2019_07_01.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2019_07_01.models.GalleryArtifactVersionSource @@ -4122,8 +4122,8 @@ class GalleryUpdate(UpdateResource): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2019_07_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_07_01.models.GalleryPropertiesProvisioningState """ @@ -4144,7 +4144,7 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, **kwargs ): """ @@ -4167,7 +4167,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read", "Write". + :ivar access: Required. Known values are: "None", "Read", "Write". :vartype access: str or ~azure.mgmt.compute.v2019_07_01.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -4186,12 +4186,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read", "Write". + :keyword access: Required. Known values are: "None", "Read", "Write". :paramtype access: str or ~azure.mgmt.compute.v2019_07_01.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -4214,8 +4214,8 @@ class HardwareProfile(msrest.serialization.Model): :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -4260,7 +4260,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -4274,8 +4274,8 @@ def __init__( :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -4340,7 +4340,7 @@ class Image(Resource): :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Possible values include: "V1", "V2". + image. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationTypes """ @@ -4370,9 +4370,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -4385,7 +4385,7 @@ def __init__( :keyword storage_profile: Specifies the storage settings for the virtual machine disks. :paramtype storage_profile: ~azure.mgmt.compute.v2019_07_01.models.ImageStorageProfile :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Possible values include: "V1", "V2". + the image. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationTypes """ @@ -4408,16 +4408,15 @@ class ImageDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -4439,13 +4438,13 @@ class ImageDisk(msrest.serialization.Model): def __init__( self, *, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -4458,16 +4457,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -4499,16 +4497,15 @@ class ImageDataDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -4540,13 +4537,13 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -4559,16 +4556,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -4650,7 +4646,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -4680,16 +4676,15 @@ class ImageOSDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -4698,10 +4693,10 @@ class ImageOSDisk(ImageDisk): ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetParameters :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemStateTypes """ @@ -4725,15 +4720,15 @@ class ImageOSDisk(ImageDisk): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -4746,16 +4741,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -4764,11 +4758,10 @@ def __init__( ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetParameters :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemStateTypes """ super(ImageOSDisk, self).__init__(snapshot=snapshot, managed_disk=managed_disk, blob_uri=blob_uri, caching=caching, disk_size_gb=disk_size_gb, storage_account_type=storage_account_type, disk_encryption_set=disk_encryption_set, **kwargs) @@ -4916,8 +4909,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -4956,7 +4949,7 @@ class ImageUpdate(UpdateResource): :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Possible values include: "V1", "V2". + image. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationTypes """ @@ -4977,9 +4970,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -4990,7 +4983,7 @@ def __init__( :keyword storage_profile: Specifies the storage settings for the virtual machine disks. :paramtype storage_profile: ~azure.mgmt.compute.v2019_07_01.models.ImageStorageProfile :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Possible values include: "V1", "V2". + the image. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationTypes """ @@ -5038,7 +5031,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2019_07_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -5060,7 +5053,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -5069,7 +5062,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2019_07_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -5110,7 +5103,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -5149,7 +5142,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -5189,7 +5182,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -5228,7 +5221,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -5267,7 +5260,7 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, provision_vm_agent: Optional[bool] = None, **kwargs ): @@ -5313,7 +5306,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -5467,8 +5460,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2019_07_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -5493,7 +5486,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -5509,8 +5502,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2019_07_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -5563,8 +5556,8 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -5583,16 +5576,16 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -5654,7 +5647,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -5674,8 +5667,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -5691,8 +5684,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -5706,7 +5698,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5737,24 +5729,24 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -5770,8 +5762,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -5785,7 +5776,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5813,8 +5804,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes """ @@ -5829,12 +5820,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -5934,9 +5925,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, require_guest_provision_signal: Optional[bool] = None, **kwargs @@ -6094,7 +6085,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -6141,8 +6132,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -6153,7 +6144,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroupType :keyword colocation_status: Describes colocation status of the Proximity Placement Group. @@ -6190,7 +6181,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -6295,8 +6286,8 @@ class RecommendedMachineConfiguration(msrest.serialization.Model): def __init__( self, *, - v_cp_us: Optional["ResourceRange"] = None, - memory: Optional["ResourceRange"] = None, + v_cp_us: Optional["_models.ResourceRange"] = None, + memory: Optional["_models.ResourceRange"] = None, **kwargs ): """ @@ -6350,7 +6341,7 @@ class RegionalReplicationStatus(msrest.serialization.Model): :ivar region: The region to which the gallery Image Version is being replicated to. :vartype region: str - :ivar state: This is the regional replication state. Possible values include: "Unknown", + :ivar state: This is the regional replication state. Known values are: "Unknown", "Replicating", "Completed", "Failed". :vartype state: str or ~azure.mgmt.compute.v2019_07_01.models.ReplicationState :ivar details: The details of the replication status. @@ -6392,8 +6383,7 @@ class ReplicationStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Possible values include: "Unknown", "InProgress", "Completed", - "Failed". + replication status flags. Known values are: "Unknown", "InProgress", "Completed", "Failed". :vartype aggregated_state: str or ~azure.mgmt.compute.v2019_07_01.models.AggregatedReplicationState :ivar summary: This is a summary of replication status for each region. @@ -6440,7 +6430,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_resource_name: Group query result by Resource Name. :vartype group_by_resource_name: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2019_07_01.models.IntervalInMins """ @@ -6467,7 +6457,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -6488,7 +6478,7 @@ def __init__( :keyword group_by_resource_name: Group query result by Resource Name. :paramtype group_by_resource_name: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2019_07_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, **kwargs) @@ -6689,13 +6679,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -6808,8 +6798,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -6838,7 +6827,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -6848,8 +6837,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -6873,8 +6861,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -6910,11 +6897,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -6922,8 +6909,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -6969,7 +6955,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -7050,7 +7036,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -7133,7 +7119,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -7172,7 +7158,7 @@ class ScaleInPolicy(msrest.serialization.Model): def __init__( self, *, - rules: Optional[List[Union[str, "VirtualMachineScaleSetScaleInRules"]]] = None, + rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, **kwargs ): """ @@ -7213,7 +7199,7 @@ class ScheduledEventsProfile(msrest.serialization.Model): def __init__( self, *, - terminate_notification_profile: Optional["TerminateNotificationProfile"] = None, + terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs ): """ @@ -7292,10 +7278,10 @@ class Snapshot(Resource): :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.SnapshotSku :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGeneration :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -7361,14 +7347,14 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, incremental: Optional[bool] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, **kwargs ): """ @@ -7378,10 +7364,10 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2019_07_01.models.SnapshotSku - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGeneration :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -7442,7 +7428,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -7463,8 +7449,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2019_07_01.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -7482,12 +7467,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2019_07_01.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -7502,7 +7486,7 @@ class SnapshotUpdate(msrest.serialization.Model): :vartype tags: dict[str, str] :ivar sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :vartype sku: ~azure.mgmt.compute.v2019_07_01.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -7531,11 +7515,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, - encryption: Optional["Encryption"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + encryption: Optional["_models.Encryption"] = None, **kwargs ): """ @@ -7543,7 +7527,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2019_07_01.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -7606,7 +7590,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -7688,9 +7672,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -7762,7 +7746,7 @@ def __init__( self, *, id: Optional[str] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -7787,7 +7771,7 @@ class TargetRegion(msrest.serialization.Model): region. This property is updatable. :vartype regional_replica_count: int :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType """ @@ -7806,7 +7790,7 @@ def __init__( *, name: str, regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, **kwargs ): """ @@ -7816,7 +7800,7 @@ def __init__( region. This property is updatable. :paramtype regional_replica_count: int :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS". + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountType """ @@ -7977,7 +7961,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2019_07_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2019_07_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -8024,7 +8008,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2019_07_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -8064,8 +8048,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2019_07_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -8085,9 +8069,9 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["AutomaticOSUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, + automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, **kwargs ): """ @@ -8095,8 +8079,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2019_07_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -8150,7 +8134,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -8400,8 +8384,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -8513,14 +8497,13 @@ class VirtualMachine(Resource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, the only supported value is 'Deallocate' and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -8592,22 +8575,22 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -8669,15 +8652,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, the only supported value is 'Deallocate' and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -8742,8 +8724,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -8939,7 +8921,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -9004,7 +8986,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -9141,8 +9123,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -9179,7 +9161,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -9311,8 +9293,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2019_07_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -9336,15 +9318,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2019_07_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -9440,8 +9422,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2019_07_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: "V1", - "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationTypes """ @@ -9470,11 +9451,11 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, + automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -9499,8 +9480,7 @@ def __init__( image. :paramtype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2019_07_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: - "V1", "V2". + :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationTypes """ @@ -9525,8 +9505,8 @@ class VirtualMachineInstanceView(msrest.serialization.Model): :vartype os_name: str :ivar os_version: The version of Operating System running on the virtual machine. :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationType :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. :vartype rdp_thumb_print: str @@ -9573,14 +9553,14 @@ def __init__( computer_name: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationType"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -9595,7 +9575,7 @@ def __init__( :keyword os_version: The version of Operating System running on the virtual machine. :paramtype os_version: str :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_07_01.models.HyperVGenerationType :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. @@ -9658,7 +9638,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -9810,21 +9790,21 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, **kwargs ): """ @@ -9916,14 +9896,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -9963,12 +9942,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -9983,14 +9962,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -10156,7 +10134,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -10187,7 +10165,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs ): """ @@ -10323,7 +10301,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2019_07_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine @@ -10348,15 +10326,15 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2019_07_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual @@ -10434,7 +10412,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -10494,7 +10472,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2019_07_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -10538,14 +10516,14 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -10563,7 +10541,7 @@ def __init__( ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2019_07_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -10654,7 +10632,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -10695,7 +10673,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -10735,7 +10713,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -10775,7 +10753,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -10796,8 +10774,8 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can - only be used with data disks, it cannot be used with OS Disk. Possible values include: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", + "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -10814,14 +10792,14 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS - can only be used with data disks, it cannot be used with OS Disk. Possible values include: + can only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_07_01.models.StorageAccountTypes @@ -10884,9 +10862,9 @@ def __init__( id: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -10967,8 +10945,8 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -10995,8 +10973,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -11005,8 +10982,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -11017,8 +10994,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk @@ -11050,16 +11027,16 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -11068,8 +11045,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -11078,8 +11054,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2019_07_01.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -11091,7 +11067,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_07_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2019_07_01.models.VirtualHardDisk @@ -11190,9 +11166,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -11279,7 +11255,7 @@ class VirtualMachineScaleSetPublicIPAddressConfiguration(msrest.serialization.Mo :vartype public_ip_prefix: ~azure.mgmt.compute.v2019_07_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2019_07_01.models.IPVersion """ @@ -11301,10 +11277,10 @@ def __init__( *, name: str, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersion"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, **kwargs ): """ @@ -11321,7 +11297,7 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2019_07_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2019_07_01.models.IPVersion """ super(VirtualMachineScaleSetPublicIPAddressConfiguration, self).__init__(**kwargs) @@ -11479,8 +11455,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -11542,9 +11517,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -11635,18 +11610,18 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - proximity_placement_group: Optional["SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -11724,7 +11699,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2019_07_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -11758,14 +11733,14 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -11783,7 +11758,7 @@ def __init__( ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2019_07_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -11854,9 +11829,9 @@ def __init__( name: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -11911,8 +11886,8 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, **kwargs ): """ @@ -11932,7 +11907,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -11964,16 +11939,16 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_07_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -12025,9 +12000,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -12070,7 +12045,7 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, **kwargs ): """ @@ -12109,9 +12084,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -12170,14 +12145,14 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, **kwargs ): """ @@ -12352,17 +12327,17 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - network_profile_configuration: Optional["VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, - protection_policy: Optional["VirtualMachineScaleSetVMProtectionPolicy"] = None, + protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, **kwargs ): """ @@ -12595,12 +12570,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -12670,7 +12645,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -12701,7 +12676,7 @@ class VirtualMachineScaleSetVMNetworkProfileConfiguration(msrest.serialization.M def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -12743,15 +12718,14 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, the only supported value is 'Deallocate' and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -12778,16 +12752,16 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, **kwargs ): """ @@ -12818,15 +12792,14 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, the only supported value is 'Deallocate' and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -12965,7 +12938,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -13067,14 +13040,13 @@ class VirtualMachineUpdate(UpdateResource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, the only supported value is 'Deallocate' and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -13135,22 +13107,22 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -13210,15 +13182,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_07_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, the only supported value is 'Deallocate' and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -13332,8 +13303,8 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -13382,7 +13353,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -13397,7 +13368,7 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :vartype protocol: str or ~azure.mgmt.compute.v2019_07_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as @@ -13418,13 +13389,13 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2019_07_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/__init__.py index 84aa626c09ed..29856efddb78 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/__init__.py @@ -34,6 +34,9 @@ from ._gallery_application_versions_operations import GalleryApplicationVersionsOperations from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations +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', 'AvailabilitySetsOperations', @@ -63,3 +66,5 @@ 'GalleryApplicationVersionsOperations', 'VirtualMachineRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_availability_sets_operations.py index eb10f7054873..2a99a747d1e3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +190,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -199,20 +205,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -235,18 +242,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -257,9 +262,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -271,51 +279,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -329,14 +333,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -348,11 +355,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -378,9 +387,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -394,14 +403,17 @@ def update( :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -413,11 +425,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,13 +470,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -471,11 +488,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -498,7 +517,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -510,13 +529,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -525,11 +547,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -555,7 +579,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -568,13 +592,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -583,9 +610,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +623,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -634,7 +665,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -646,13 +677,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +695,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -672,9 +708,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -713,7 +751,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -728,13 +766,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -756,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_dedicated_host_groups_operations.py index f29cb63734f8..85ae589f2bf5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_dedicated_host_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -186,9 +189,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -199,18 +205,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -219,9 +223,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") path_format_arguments = { @@ -231,51 +238,47 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostGroupsOperations(object): - """DedicatedHostGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -291,14 +294,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -310,11 +316,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -344,9 +352,9 @@ def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -360,14 +368,17 @@ def update( :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -379,11 +390,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -422,13 +435,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -437,11 +453,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -464,7 +482,7 @@ def get( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -476,13 +494,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -491,11 +512,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -521,7 +544,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -534,13 +557,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -549,9 +575,11 @@ def prepare_request(next_link=None): 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: @@ -560,9 +588,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -599,7 +629,7 @@ def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -610,13 +640,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -624,9 +657,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -634,9 +669,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_dedicated_hosts_operations.py index 1c4bd15c6a0c..9e16957b2adc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHost] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_by_host_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_by_host_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostsOperations(object): - """DedicatedHostsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -341,17 +348,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -359,20 +369,27 @@ def begin_create_or_update( 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('DedicatedHost', 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( @@ -390,17 +407,20 @@ def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -413,11 +433,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -444,9 +466,9 @@ def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -470,17 +492,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -488,20 +513,27 @@ def begin_update( 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('DedicatedHost', 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( @@ -521,13 +553,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements host_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -537,11 +572,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -586,21 +623,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -610,8 +652,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -632,7 +680,7 @@ def get( host_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -641,21 +689,24 @@ def get( :type host_group_name: str :param host_name: The name of the dedicated host. :type host_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedHost, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_07_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -666,11 +717,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +750,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostListResult"]: + ) -> Iterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -712,13 +765,16 @@ def list_by_host_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -728,9 +784,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -740,9 +798,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_disk_encryption_sets_operations.py index c8c6915b43ce..f69fd639811f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") path_format_arguments = { @@ -239,58 +247,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskEncryptionSetsOperations(object): - """DiskEncryptionSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -302,11 +309,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -336,9 +345,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -363,37 +372,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -410,17 +429,20 @@ def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -432,11 +454,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -466,9 +490,9 @@ def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -493,37 +517,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -542,7 +576,7 @@ def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -556,13 +590,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -571,11 +608,13 @@ def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -602,13 +641,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -617,11 +659,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -665,20 +709,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -688,8 +737,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -707,7 +762,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -719,13 +774,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -734,9 +792,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -745,9 +805,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -784,7 +846,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -794,13 +856,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -808,9 +873,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -818,9 +885,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_disks_operations.py index 0b04886a0df3..dd78709290f6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_galleries_operations.py index 0119a043f720..8575817dcfbf 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.Gallery] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") path_format_arguments = { @@ -239,58 +247,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleriesOperations(object): - """GalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -302,11 +309,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -339,9 +348,9 @@ def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -363,37 +372,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -410,17 +429,20 @@ def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'GalleryUpdate') @@ -432,11 +454,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -462,9 +486,9 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -486,37 +510,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -535,7 +569,7 @@ def get( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -547,13 +581,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -562,11 +599,13 @@ def get( gallery_name=gallery_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,13 +632,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -608,11 +650,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -654,20 +698,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -677,8 +726,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -696,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -706,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -721,9 +779,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -732,9 +792,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -771,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -779,13 +841,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -793,9 +858,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -803,9 +870,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_application_versions_operations.py index 706cc56adf3d..a5e6d0adbd32 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +137,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +156,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -177,9 +180,12 @@ def build_delete_request_initial( gallery_application_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +199,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -216,9 +220,12 @@ def build_list_by_gallery_application_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -231,42 +238,38 @@ def build_list_by_gallery_application_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationVersionsOperations(object): - """GalleryApplicationVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -274,17 +277,20 @@ def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -298,11 +304,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -373,17 +381,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -392,20 +403,27 @@ def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -424,17 +442,20 @@ def _update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersionUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,9 +503,9 @@ def begin_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -516,17 +539,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -535,20 +561,27 @@ def begin_update( 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('GalleryApplicationVersion', 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( @@ -570,7 +603,7 @@ def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -591,13 +624,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -609,11 +645,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -642,13 +680,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -659,11 +700,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -714,22 +757,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -739,8 +787,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -760,7 +814,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationVersionList"]: + ) -> Iterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -778,13 +832,16 @@ def list_by_gallery_application( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +852,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -808,9 +867,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_applications_operations.py index eb4505eaf450..b313558d01f6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplication] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_get_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -181,18 +187,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +207,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications") # pylint: disable=line-too-long path_format_arguments = { @@ -217,59 +224,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationsOperations(object): - """GalleryApplicationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -282,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -320,9 +328,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -351,17 +359,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -369,20 +380,27 @@ def begin_create_or_update( 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('GalleryApplication', 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( @@ -400,17 +418,20 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplicationUpdate') @@ -423,11 +444,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -454,9 +477,9 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -484,17 +507,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -502,20 +528,27 @@ def begin_update( 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('GalleryApplication', 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( @@ -535,7 +568,7 @@ def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -551,13 +584,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -567,11 +603,13 @@ def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -599,13 +637,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -615,11 +656,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -665,21 +708,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -689,8 +737,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -709,7 +763,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationList"]: + ) -> Iterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -724,13 +778,16 @@ def list_by_gallery( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -740,9 +797,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -752,9 +811,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_image_versions_operations.py index 9922d1af01a3..b6284382ca9f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +137,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +156,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -177,9 +180,12 @@ def build_delete_request_initial( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +199,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -216,9 +220,12 @@ def build_list_by_gallery_image_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -231,42 +238,38 @@ def build_list_by_gallery_image_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImageVersionsOperations(object): - """GalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -274,17 +277,20 @@ def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -298,11 +304,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Create or update a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -372,17 +380,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -423,17 +441,20 @@ def _update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersionUpdate') @@ -447,11 +468,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -479,9 +502,9 @@ def begin_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Update a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -514,17 +537,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -533,20 +559,27 @@ def begin_update( 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('GalleryImageVersion', 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( @@ -568,7 +601,7 @@ def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -588,13 +621,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -606,11 +642,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -639,13 +677,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -656,11 +697,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -710,22 +753,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -735,8 +783,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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,7 +810,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageVersionList"]: + ) -> Iterable[_models.GalleryImageVersionList]: """List gallery Image Versions in a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -774,13 +828,16 @@ def list_by_gallery_image( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -791,9 +848,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -804,9 +863,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_images_operations.py index 55d5f78961b6..66309706d364 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImage] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -181,18 +187,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +207,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images") # pylint: disable=line-too-long path_format_arguments = { @@ -217,59 +224,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImagesOperations(object): - """GalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -282,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -320,9 +328,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Create or update a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -349,17 +357,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -367,20 +378,27 @@ def begin_create_or_update( 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('GalleryImage', 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( @@ -398,17 +416,20 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImageUpdate') @@ -421,11 +442,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +475,9 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Update a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -481,17 +504,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -499,20 +525,27 @@ def begin_update( 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('GalleryImage', 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( @@ -532,7 +565,7 @@ def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -547,13 +580,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -563,11 +599,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,13 +633,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -611,11 +652,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -661,21 +704,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +733,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +759,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageList"]: + ) -> Iterable[_models.GalleryImageList]: """List gallery Image Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -718,13 +772,16 @@ def list_by_gallery( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -734,9 +791,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -746,9 +805,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_images_operations.py index 856469ffbbd9..83d490af220a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -155,9 +157,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +174,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -192,9 +195,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -205,18 +211,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +229,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -237,58 +244,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -300,11 +306,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -334,9 +342,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -357,37 +365,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -404,17 +422,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -426,11 +447,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -460,9 +483,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -483,37 +506,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -532,13 +565,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -547,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,20 +631,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -616,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -637,7 +686,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -651,13 +700,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -667,11 +719,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -707,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -722,9 +779,11 @@ def prepare_request(next_link=None): 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: @@ -733,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -772,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -781,13 +842,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -805,9 +871,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_log_analytics_operations.py index ef4ade883db2..c0fa7c4a8aa5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_operations.py index 36aed9fa6ae1..5ece8825d4e5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_proximity_placement_groups_operations.py index 03bb79092a9f..7d9ee8903ece 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( include_colocation_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +172,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if include_colocation_status is not None: - _query_parameters['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -189,9 +192,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -235,51 +242,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -293,14 +296,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -312,11 +318,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -346,9 +354,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -362,14 +370,17 @@ def update( :rtype: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -381,11 +392,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -424,13 +437,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -439,11 +455,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -467,7 +485,7 @@ def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -482,13 +500,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -498,11 +519,13 @@ def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +550,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -537,13 +560,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -551,9 +577,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -561,9 +589,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -601,7 +631,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -613,13 +643,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -628,9 +661,11 @@ def prepare_request(next_link=None): 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: @@ -639,9 +674,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_snapshots_operations.py index 6ed670e686ff..94be0c2fe665 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_usage_operations.py index 736a0cb633cd..9709a5aa229e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_extension_images_operations.py index e42a89460d1a..5174aec67da2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_extensions_operations.py index 862545e769ae..b05d8b0a9748 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,8 +129,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -141,13 +144,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -161,9 +163,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -176,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -202,9 +205,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -216,61 +222,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -283,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -318,9 +325,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -347,17 +354,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -365,20 +375,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -396,17 +413,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -419,11 +439,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,9 +472,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -479,17 +501,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -497,20 +522,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -530,13 +562,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -546,11 +581,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,21 +632,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -619,8 +661,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -641,7 +689,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -657,13 +705,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -674,11 +725,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -706,7 +759,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -720,13 +773,16 @@ def list( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -736,11 +792,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_images_operations.py index aea695c13007..7f030dd420a5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_run_commands_operations.py index 8798bb1e0c43..bcdf9f350b3e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_run_commands_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -44,18 +48,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -66,9 +68,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -80,49 +85,45 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -134,13 +135,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -149,9 +153,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -160,9 +166,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -201,7 +209,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -213,13 +221,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -228,11 +239,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_extensions_operations.py index 865a4542613c..faa0ce409329 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -345,17 +352,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -363,20 +373,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -394,17 +411,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -417,11 +437,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +474,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -481,17 +503,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -499,20 +524,27 @@ def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -532,13 +564,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -548,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -597,21 +634,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -621,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -643,7 +691,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -659,13 +707,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -676,11 +727,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -707,7 +760,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -721,13 +774,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -737,9 +793,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -749,9 +807,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index d571930785ed..35e14ab6ba9f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,8 +34,9 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -46,13 +48,12 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -63,8 +64,9 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -76,13 +78,12 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -93,8 +94,9 @@ def build_start_extension_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -106,13 +108,12 @@ def build_start_extension_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -123,9 +124,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -137,42 +141,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -180,13 +180,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -195,11 +198,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,20 +246,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -264,8 +274,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -284,13 +300,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -299,11 +318,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,20 +368,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -370,8 +396,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -390,13 +422,16 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -405,11 +440,13 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -453,20 +490,25 @@ def begin_start_extension_upgrade( # pylint: disable=inconsistent-return-statem :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_extension_upgrade_initial( + raw_result = self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -476,8 +518,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -496,7 +544,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -508,13 +556,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2019_07_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -523,11 +574,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py index 93a1ab3915ff..5c4a86067ec8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -56,20 +59,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -83,14 +84,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -104,20 +108,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -132,9 +134,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -148,18 +153,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -174,9 +177,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -190,20 +196,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -217,9 +221,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -232,44 +239,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMExtensionsOperations(object): - """VirtualMachineScaleSetVMExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -277,17 +280,20 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -301,11 +307,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -367,17 +375,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -386,20 +397,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -418,17 +436,20 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -442,11 +463,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -474,9 +497,9 @@ def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -505,17 +528,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -524,20 +550,27 @@ def begin_update( 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('VirtualMachineExtension', 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 +591,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -575,11 +611,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -627,22 +665,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -652,8 +695,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -675,7 +724,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -693,13 +742,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -711,11 +763,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -744,7 +798,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -760,13 +814,16 @@ def list( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -777,11 +834,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_vms_operations.py index 3b6034a21850..140ce04af98b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,13 +35,15 @@ def build_reimage_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -54,19 +56,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,8 +80,9 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -94,13 +95,12 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -112,8 +112,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -126,13 +127,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -143,14 +143,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -163,20 +166,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -190,8 +191,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -204,13 +206,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -224,9 +225,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -239,20 +243,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -264,9 +266,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -279,18 +284,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -305,9 +308,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -319,24 +325,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -350,8 +354,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -364,15 +369,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -384,8 +388,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -398,13 +403,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -416,8 +420,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -430,13 +435,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -448,8 +452,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -462,13 +467,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -480,8 +484,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -494,13 +499,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -511,14 +515,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -531,63 +538,62 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -603,11 +609,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -630,7 +638,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -657,17 +665,20 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -675,6 +686,8 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -684,8 +697,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,13 +724,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -721,11 +743,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -771,21 +795,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -795,8 +824,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -816,13 +851,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -832,11 +870,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -883,21 +923,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -907,8 +952,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -926,17 +977,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -949,11 +1003,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -984,9 +1040,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1012,17 +1068,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1030,20 +1089,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1063,13 +1129,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1079,11 +1148,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1128,21 +1199,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1152,8 +1228,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1174,7 +1256,7 @@ def get( instance_id: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1183,21 +1265,24 @@ def get( :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. :type instance_id: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachineScaleSetVM, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1208,11 +1293,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1240,7 +1327,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1254,13 +1341,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1270,11 +1360,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1304,7 +1396,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1328,13 +1420,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1347,9 +1442,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1362,9 +1459,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1405,13 +1504,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1422,11 +1524,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1478,22 +1582,27 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1503,8 +1612,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1524,13 +1639,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1540,11 +1658,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1589,21 +1709,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1613,8 +1738,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1634,13 +1765,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1650,11 +1784,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1699,21 +1835,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1723,8 +1864,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1744,13 +1891,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1760,11 +1910,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1810,21 +1962,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1834,8 +1991,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1855,13 +2018,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1871,11 +2037,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1921,21 +2089,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1945,8 +2118,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1964,18 +2143,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1988,11 +2170,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2021,11 +2205,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2036,7 +2220,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2019_07_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2052,16 +2236,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2069,20 +2256,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_sets_operations.py index 186762da69b7..9c30713035a4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,18 +172,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -188,13 +191,15 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -206,19 +211,17 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -230,13 +233,15 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -248,19 +253,17 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -273,9 +276,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -287,18 +293,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -308,9 +312,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -321,18 +328,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -341,9 +346,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -353,18 +361,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -375,9 +381,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -389,18 +398,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -411,9 +418,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -425,18 +435,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -446,14 +454,16 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -465,21 +475,19 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -491,13 +499,15 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -509,19 +519,17 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -533,13 +541,15 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -551,19 +561,17 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -575,13 +583,15 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -593,19 +603,17 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -617,13 +625,15 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -635,19 +645,17 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -659,13 +667,15 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -677,19 +687,17 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -701,13 +709,15 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -719,19 +729,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -743,13 +751,15 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -761,19 +771,17 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -788,9 +796,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( platform_update_domain: int, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -802,19 +813,17 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -824,13 +833,15 @@ def build_convert_to_single_placement_group_request( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VMScaleSetConvertToSinglePlacementGroupInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup") # pylint: disable=line-too-long path_format_arguments = { @@ -842,61 +853,60 @@ def build_convert_to_single_placement_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -908,11 +918,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -942,9 +954,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -967,37 +979,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1014,17 +1036,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -1036,11 +1061,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1066,9 +1093,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1091,37 +1118,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1140,13 +1177,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1155,11 +1195,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1201,20 +1243,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1224,8 +1271,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1244,7 +1297,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1256,13 +1309,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1271,11 +1327,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1300,17 +1358,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1325,11 +1386,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1351,7 +1414,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1378,23 +1441,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1404,8 +1472,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1422,17 +1496,20 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1444,11 +1521,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1470,7 +1549,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -1494,23 +1573,28 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1520,8 +1604,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1540,7 +1630,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1552,13 +1642,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1567,11 +1660,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1597,7 +1692,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1609,13 +1704,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1624,9 +1722,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1635,9 +1735,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1674,7 +1776,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1686,13 +1788,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1700,9 +1805,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1710,9 +1817,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1751,7 +1860,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1766,13 +1875,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1782,9 +1894,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1794,9 +1908,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1835,7 +1951,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1849,13 +1965,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1865,9 +1984,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1877,9 +1998,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1917,17 +2040,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1943,11 +2069,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1970,7 +2098,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -2001,17 +2129,20 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -2019,6 +2150,8 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2028,8 +2161,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2046,17 +2185,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2071,11 +2213,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2097,7 +2241,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2122,23 +2266,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2148,8 +2297,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2166,17 +2321,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2191,11 +2349,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2217,7 +2377,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2242,23 +2402,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2268,8 +2433,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2286,17 +2457,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2311,11 +2485,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2337,7 +2513,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2363,23 +2539,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2389,8 +2570,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2407,17 +2594,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2432,11 +2622,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2458,7 +2650,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2486,23 +2678,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2512,8 +2709,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2530,17 +2733,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2552,11 +2758,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2578,7 +2786,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2602,23 +2810,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2628,8 +2841,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2646,17 +2865,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -2671,11 +2893,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2697,7 +2921,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -2723,23 +2947,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2749,8 +2978,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2767,17 +3002,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2792,11 +3030,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2818,7 +3058,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2844,23 +3084,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2870,8 +3115,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2891,7 +3142,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2907,13 +3158,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2019_07_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2923,11 +3177,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2953,7 +3209,7 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to true for a existing virtual machine scale set. @@ -2970,14 +3226,17 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st :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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -2989,11 +3248,13 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_sizes_operations.py index 333091724754..aaa564327d73 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -99,13 +99,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machines_operations.py index 1128b3f340d8..3faef26c16c5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_07_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -201,8 +205,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -214,13 +219,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -233,9 +237,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -247,20 +254,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -271,9 +276,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -285,18 +293,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -307,8 +313,9 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -320,13 +327,12 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -337,8 +343,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -350,13 +357,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -367,8 +373,9 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -380,13 +387,12 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -396,9 +402,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -409,18 +418,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -431,9 +438,12 @@ def build_list_all_request( status_only: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -443,20 +453,18 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 status_only is not None: - _query_parameters['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') + _params['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -467,9 +475,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -481,18 +492,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -505,8 +514,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -518,15 +528,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -537,9 +546,12 @@ def build_reapply_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply") # pylint: disable=line-too-long path_format_arguments = { @@ -551,18 +563,16 @@ def build_reapply_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -573,8 +583,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -586,13 +597,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -603,8 +613,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -616,13 +627,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -633,8 +643,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -646,13 +657,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -662,13 +672,15 @@ def build_reimage_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -680,19 +692,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -705,8 +715,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -718,13 +729,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -734,14 +744,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -753,53 +766,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2019_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.compute.v2019_07_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -811,13 +820,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -826,9 +838,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -837,9 +851,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -876,17 +892,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -898,11 +917,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -930,9 +951,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -956,37 +977,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -1003,17 +1034,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -1025,11 +1059,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1059,9 +1095,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -1084,37 +1120,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1131,17 +1177,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1153,11 +1202,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1187,9 +1238,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1211,37 +1262,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1260,13 +1321,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1275,11 +1339,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1321,20 +1387,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1344,8 +1415,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1365,28 +1442,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1396,11 +1476,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1427,7 +1509,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1439,13 +1521,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2019_07_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1454,11 +1539,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1485,13 +1572,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1500,11 +1590,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1551,20 +1643,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1574,8 +1671,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1594,13 +1697,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -1609,11 +1715,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1656,20 +1764,25 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1679,8 +1792,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1716,13 +1835,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1731,11 +1853,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1757,7 +1881,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1770,13 +1894,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1785,9 +1912,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1796,9 +1925,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1836,7 +1967,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1850,13 +1981,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1865,9 +1999,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1876,9 +2012,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1917,7 +2055,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1932,13 +2070,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_07_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1948,9 +2089,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1960,9 +2103,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2002,13 +2147,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -2018,11 +2166,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2070,21 +2220,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2094,8 +2249,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2114,13 +2275,16 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -2129,11 +2293,13 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2175,20 +2341,25 @@ def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reapply_initial( + raw_result = self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2198,8 +2369,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2218,13 +2395,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2233,11 +2413,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2279,20 +2461,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2302,8 +2489,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2322,13 +2515,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2337,11 +2533,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2383,20 +2581,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2406,8 +2609,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2426,13 +2635,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2441,11 +2653,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2487,20 +2701,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2510,8 +2729,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2528,17 +2753,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -2553,11 +2781,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2579,7 +2809,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -2603,23 +2833,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -2629,8 +2864,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2649,13 +2890,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2664,11 +2908,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2711,20 +2957,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2734,8 +2985,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2752,18 +3009,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2775,11 +3035,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2807,11 +3069,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2820,7 +3082,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2019_07_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2836,36 +3098,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_07_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/_compute_management_client.py index de57ce87e0ff..43f4862176d9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/_compute_management_client.py @@ -60,9 +60,15 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/_compute_management_client.py index 21133a5b1f0c..5d0bf41dd5ed 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/_compute_management_client.py @@ -60,9 +60,15 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/__init__.py index c280f94ec071..0d28b504be95 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/__init__.py @@ -10,8 +10,13 @@ from ._snapshots_operations import SnapshotsOperations from ._disk_encryption_sets_operations import DiskEncryptionSetsOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', 'DiskEncryptionSetsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_disk_encryption_sets_operations.py index 17b531bccf3f..a2c77842e138 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskEncryptionSetsOperations: - """DiskEncryptionSetsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_11_01.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_11_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -238,9 +257,9 @@ async def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -266,37 +285,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_11_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -315,7 +344,7 @@ async def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -329,13 +358,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_11_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -344,11 +376,13 @@ async def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -375,13 +409,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -390,11 +427,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,20 +477,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -461,8 +505,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -480,7 +530,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -492,13 +542,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_11_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -507,9 +560,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -518,9 +573,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -557,7 +614,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -567,13 +624,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_11_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -581,9 +641,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -591,9 +653,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_disks_operations.py index 49f7c451be1a..3c3383c71d42 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2019_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.compute.v2019_11_01.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_11_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_11_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_11_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_11_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_11_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_11_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_snapshots_operations.py index a91e934ae5f7..694c46afb655 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_11_01.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_11_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_11_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_11_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_11_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_11_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_11_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/__init__.py index 4fdd463855a1..5cd19e6c0d13 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/__init__.py @@ -46,7 +46,9 @@ OperatingSystemTypes, SnapshotStorageAccountTypes, ) - +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__ = [ 'AccessUri', 'ApiError', @@ -85,3 +87,5 @@ 'OperatingSystemTypes', 'SnapshotStorageAccountTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/_compute_management_client_enums.py index 8a8007eef28a..562a61a9167d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/_compute_management_client_enums.py @@ -7,17 +7,16 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" WRITE = "Write" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -40,13 +39,13 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the disk. UPLOAD = "Upload" -class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported. """ SYSTEM_ASSIGNED = "SystemAssigned" -class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the disk. """ @@ -63,7 +62,7 @@ class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: A disk is created for upload and a write token has been issued for uploading to it. ACTIVE_UPLOAD = "ActiveUpload" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -78,7 +77,7 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: databases (for example, SQL, Oracle), and other transaction-heavy workloads. ULTRA_SSD_LRS = "UltraSSD_LRS" -class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -87,21 +86,21 @@ class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Disk is encrypted with Customer managed key at rest. ENCRYPTION_AT_REST_WITH_CUSTOMER_KEY = "EncryptionAtRestWithCustomerKey" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/_models_py3.py index 087181ceb074..fce0dc02c65c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -66,8 +68,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -139,8 +141,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :vartype create_option: str or ~azure.mgmt.compute.v2019_11_01.models.DiskCreateOption :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -185,10 +187,10 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, - gallery_image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, + gallery_image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, upload_size_bytes: Optional[int] = None, @@ -196,7 +198,7 @@ def __init__( ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :paramtype create_option: str or ~azure.mgmt.compute.v2019_11_01.models.DiskCreateOption :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -314,10 +316,10 @@ class Disk(Resource): :vartype zones: list[str] :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_11_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_11_01.models.HyperVGeneration :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -351,7 +353,7 @@ class Disk(Resource): mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. :vartype disk_m_bps_read_only: long - :ivar disk_state: The state of the disk. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", "Reserved", "ActiveSAS", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2019_11_01.models.DiskState :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed @@ -414,18 +416,18 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - creation_data: Optional["CreationData"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, max_shares: Optional[int] = None, **kwargs ): @@ -439,10 +441,10 @@ def __init__( :paramtype sku: ~azure.mgmt.compute.v2019_11_01.models.DiskSku :keyword zones: The Logical zone list for Disk. :paramtype zones: list[str] - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_11_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_11_01.models.HyperVGeneration :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -557,8 +559,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - active_key: Optional["KeyVaultAndKeyReference"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + active_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -603,7 +605,7 @@ class DiskEncryptionSetList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskEncryptionSet"], + value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs ): @@ -638,7 +640,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - active_key: Optional["KeyVaultAndKeyReference"] = None, + active_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -677,7 +679,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -698,8 +700,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS". :vartype name: str or ~azure.mgmt.compute.v2019_11_01.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -717,11 +719,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype name: str or ~azure.mgmt.compute.v2019_11_01.models.DiskStorageAccountTypes """ @@ -738,7 +740,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :vartype sku: ~azure.mgmt.compute.v2019_11_01.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_11_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -789,16 +791,16 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, max_shares: Optional[int] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, **kwargs ): """ @@ -807,7 +809,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :paramtype sku: ~azure.mgmt.compute.v2019_11_01.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_11_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -859,7 +861,7 @@ class Encryption(msrest.serialization.Model): :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Possible values include: + :ivar type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey". :vartype type: str or ~azure.mgmt.compute.v2019_11_01.models.EncryptionType """ @@ -873,14 +875,14 @@ def __init__( self, *, disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "EncryptionType"]] = None, + type: Optional[Union[str, "_models.EncryptionType"]] = None, **kwargs ): """ :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Possible values include: + :keyword type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey". :paramtype type: str or ~azure.mgmt.compute.v2019_11_01.models.EncryptionType """ @@ -895,7 +897,7 @@ class EncryptionSetIdentity(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is - supported. Possible values include: "SystemAssigned". + supported. Known values are: "SystemAssigned". :vartype type: str or ~azure.mgmt.compute.v2019_11_01.models.DiskEncryptionSetIdentityType :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a @@ -921,12 +923,12 @@ class EncryptionSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "DiskEncryptionSetIdentityType"]] = None, + type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, **kwargs ): """ :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned - is supported. Possible values include: "SystemAssigned". + is supported. Known values are: "SystemAssigned". :paramtype type: str or ~azure.mgmt.compute.v2019_11_01.models.DiskEncryptionSetIdentityType """ super(EncryptionSetIdentity, self).__init__(**kwargs) @@ -968,7 +970,7 @@ def __init__( self, *, enabled: bool, - encryption_settings: Optional[List["EncryptionSettingsElement"]] = None, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, encryption_settings_version: Optional[str] = None, **kwargs ): @@ -1010,8 +1012,8 @@ class EncryptionSettingsElement(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -1032,7 +1034,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read", "Write". + :ivar access: Required. Known values are: "None", "Read", "Write". :vartype access: str or ~azure.mgmt.compute.v2019_11_01.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -1051,12 +1053,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read", "Write". + :keyword access: Required. Known values are: "None", "Read", "Write". :paramtype access: str or ~azure.mgmt.compute.v2019_11_01.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -1164,7 +1166,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -1203,7 +1205,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -1268,10 +1270,10 @@ class Snapshot(Resource): :vartype sku: ~azure.mgmt.compute.v2019_11_01.models.SnapshotSku :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_11_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_11_01.models.HyperVGeneration :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1337,14 +1339,14 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, incremental: Optional[bool] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, **kwargs ): """ @@ -1354,10 +1356,10 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2019_11_01.models.SnapshotSku - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_11_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_11_01.models.HyperVGeneration :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1418,7 +1420,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -1439,8 +1441,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2019_11_01.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -1458,12 +1459,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2019_11_01.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -1478,7 +1478,7 @@ class SnapshotUpdate(msrest.serialization.Model): :vartype tags: dict[str, str] :ivar sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :vartype sku: ~azure.mgmt.compute.v2019_11_01.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_11_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1507,11 +1507,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, - encryption: Optional["Encryption"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + encryption: Optional["_models.Encryption"] = None, **kwargs ): """ @@ -1519,7 +1519,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2019_11_01.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_11_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/__init__.py index c280f94ec071..0d28b504be95 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/__init__.py @@ -10,8 +10,13 @@ from ._snapshots_operations import SnapshotsOperations from ._disk_encryption_sets_operations import DiskEncryptionSetsOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', 'DiskEncryptionSetsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_disk_encryption_sets_operations.py index f7798b213813..ef2cc36e963b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") path_format_arguments = { @@ -239,58 +247,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskEncryptionSetsOperations(object): - """DiskEncryptionSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_11_01.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -302,11 +309,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -336,9 +345,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -363,37 +372,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_11_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -410,17 +429,20 @@ def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -432,11 +454,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -466,9 +490,9 @@ def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -493,37 +517,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_11_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -542,7 +576,7 @@ def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -556,13 +590,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_11_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -571,11 +608,13 @@ def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -602,13 +641,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -617,11 +659,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -665,20 +709,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -688,8 +737,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -707,7 +762,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -719,13 +774,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_11_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -734,9 +792,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -745,9 +805,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -784,7 +846,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -794,13 +856,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_11_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -808,9 +873,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -818,9 +885,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_disks_operations.py index a727787de839..bf6914382350 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_11_01.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_11_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_11_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_11_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_11_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_11_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_11_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2019-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_snapshots_operations.py index cbf06ebe8713..a032a2e8875b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_11_01/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_11_01.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_11_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_11_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_11_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_11_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_11_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_11_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2019-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_compute_management_client.py index fa76541f1513..074e525632e5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_compute_management_client.py @@ -122,31 +122,81 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/_compute_management_client.py index 32836626fa02..186080dce082 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/_compute_management_client.py @@ -124,31 +124,81 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/__init__.py index 7d409a1b87d4..c1c277fa7bc6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/__init__.py @@ -32,6 +32,9 @@ from ._gallery_applications_operations import GalleryApplicationsOperations from ._gallery_application_versions_operations import GalleryApplicationVersionsOperations +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', 'AvailabilitySetsOperations', @@ -59,3 +62,5 @@ 'GalleryApplicationsOperations', 'GalleryApplicationVersionsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_availability_sets_operations.py index 2d5096f54038..f8ccbebb7fe0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_dedicated_host_groups_operations.py index 5a0707fb568b..899065dfeb1b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_dedicated_host_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostGroupsOperations: - """DedicatedHostGroupsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -137,14 +141,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -156,11 +163,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -199,13 +208,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,11 +226,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,7 +255,7 @@ async def get( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -253,13 +267,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -268,11 +285,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -298,7 +317,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -311,13 +330,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -326,9 +348,11 @@ def prepare_request(next_link=None): 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: @@ -337,9 +361,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +402,7 @@ async def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -387,13 +413,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,9 +430,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -411,9 +442,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_dedicated_hosts_operations.py index 8299b3db050d..2a4842e183fc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostsOperations: - """DedicatedHostsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('DedicatedHost', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -267,17 +286,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -285,20 +307,27 @@ async def begin_update( 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('DedicatedHost', 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( @@ -318,13 +347,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -334,11 +366,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,21 +417,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -407,8 +446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -429,7 +474,7 @@ async def get( host_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -438,21 +483,24 @@ async def get( :type host_group_name: str :param host_name: The name of the dedicated host. :type host_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedHost, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -463,11 +511,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -494,7 +544,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostListResult"]: + ) -> AsyncIterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -509,13 +559,16 @@ def list_by_host_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -525,9 +578,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -537,9 +592,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_galleries_operations.py index 060500305d8d..b58dd6a36da8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleriesOperations: - """GalleriesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Gallery] _json = self._serialize.body(gallery, 'GalleryUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -234,9 +253,9 @@ async def begin_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -259,37 +278,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -308,7 +337,7 @@ async def get( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -320,13 +349,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -335,11 +367,13 @@ async def get( gallery_name=gallery_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,13 +400,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -381,11 +418,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -427,20 +466,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -450,8 +494,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -469,7 +519,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -480,13 +530,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -495,9 +548,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -506,9 +561,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -545,7 +602,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -554,13 +611,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -568,9 +628,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -578,9 +640,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_application_versions_operations.py index 2404f24e7dff..3cb9bdc2081f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationVersionsOperations: - """GalleryApplicationVersionsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -152,17 +156,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -171,20 +178,27 @@ async def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -203,17 +217,20 @@ async def _update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersionUpdate') @@ -227,11 +244,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -259,9 +278,9 @@ async def begin_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -295,17 +314,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -314,20 +336,27 @@ async def begin_update( 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('GalleryApplicationVersion', 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( @@ -349,7 +378,7 @@ async def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -370,13 +399,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -388,11 +420,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -421,13 +455,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -438,11 +475,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -493,22 +532,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -518,8 +562,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -539,7 +589,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationVersionList"]: + ) -> AsyncIterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -557,13 +607,16 @@ def list_by_gallery_application( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -574,9 +627,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -587,9 +642,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_applications_operations.py index 0536d04791cf..e40997740177 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationsOperations: - """GalleryApplicationsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -144,17 +148,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -162,20 +169,27 @@ async def begin_create_or_update( 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('GalleryApplication', 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( @@ -193,17 +207,20 @@ async def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplicationUpdate') @@ -216,11 +233,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -277,17 +296,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -295,20 +317,27 @@ async def begin_update( 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('GalleryApplication', 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( @@ -328,7 +357,7 @@ async def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -344,13 +373,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -360,11 +392,13 @@ async def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,13 +426,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -408,11 +445,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,21 +497,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -482,8 +526,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -502,7 +552,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationList"]: + ) -> AsyncIterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -517,13 +567,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -533,9 +586,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -545,9 +600,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_image_versions_operations.py index 375e19141b06..5c09d3d04959 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImageVersionsOperations: - """GalleryImageVersionsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Create or update a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -151,17 +155,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -170,20 +177,27 @@ async def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -202,17 +216,20 @@ async def _update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersionUpdate') @@ -226,11 +243,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -258,9 +277,9 @@ async def begin_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Update a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -293,17 +312,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -312,20 +334,27 @@ async def begin_update( 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('GalleryImageVersion', 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( @@ -347,7 +376,7 @@ async def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -367,13 +396,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -385,11 +417,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -418,13 +452,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -435,11 +472,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -489,22 +528,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -514,8 +558,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -535,7 +585,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageVersionList"]: + ) -> AsyncIterable[_models.GalleryImageVersionList]: """List gallery Image Versions in a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -553,13 +603,16 @@ def list_by_gallery_image( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +623,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +638,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_images_operations.py index 0da6ac4b57ca..14e772b7650e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImagesOperations: - """GalleryImagesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Create or update a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -160,20 +167,27 @@ async def begin_create_or_update( 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('GalleryImage', 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( @@ -191,17 +205,20 @@ async def _update_initial( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImageUpdate') @@ -214,11 +231,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -245,9 +264,9 @@ async def begin_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Update a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -274,17 +293,20 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -292,20 +314,27 @@ async def begin_update( 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('GalleryImage', 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( @@ -325,7 +354,7 @@ async def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -340,13 +369,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -356,11 +388,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -388,13 +422,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -404,11 +441,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -454,21 +493,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -478,8 +522,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -498,7 +548,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageList"]: + ) -> AsyncIterable[_models.GalleryImageList]: """List gallery Image Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -512,13 +562,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -528,9 +581,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -540,9 +595,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_images_operations.py index 6a801a4f4746..b9c03344e76f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_log_analytics_operations.py index 9881f989f5e7..1b308b8aacb3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_operations.py index 6daad53f0e91..a619cd21ee9c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_proximity_placement_groups_operations.py index d31afd72dabf..51e2b98452c7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,7 +254,7 @@ async def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -255,13 +269,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -271,11 +288,13 @@ async def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -300,7 +319,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -310,13 +329,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -324,9 +346,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -334,9 +358,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -374,7 +400,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -386,13 +412,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,9 +430,11 @@ def prepare_request(next_link=None): 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: @@ -412,9 +443,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_ssh_public_keys_operations.py index 9e4bcd7a75b8..f55eb9f4b3cf 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_ssh_public_keys_operations.py @@ -15,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 @@ -24,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SshPublicKeysOperations: - """SshPublicKeysOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -60,13 +59,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -74,9 +76,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -84,9 +88,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +130,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -137,13 +143,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -152,9 +161,11 @@ def prepare_request(next_link=None): 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: @@ -163,9 +174,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -203,9 +216,9 @@ async def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -219,14 +232,17 @@ async def create( :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -238,11 +254,13 @@ async def create( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -272,9 +290,9 @@ async def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -288,14 +306,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -307,11 +328,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -350,13 +373,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -365,11 +391,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,7 +420,7 @@ async def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -404,13 +432,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -419,11 +450,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,7 +483,7 @@ async def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -464,13 +497,16 @@ async def generate_key_pair( :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -479,11 +515,13 @@ async def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_usage_operations.py index 830b64c1d1a8..6e6774c48256 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_extension_images_operations.py index 234987290ffa..eb5b743b9fa7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_extensions_operations.py index 4001e52c4bd4..0987fa916f29 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_images_operations.py index 97771cecce63..74edd4995279 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_run_commands_operations.py index 247e0a3679af..80cad89f9895 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -15,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 @@ -24,33 +25,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,7 +135,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -141,13 +147,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -156,11 +165,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index 9a1d0ccc2408..ee358975b6b3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -189,17 +203,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -212,11 +229,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -276,17 +295,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -294,20 +316,27 @@ async def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -327,13 +356,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -343,11 +375,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,21 +426,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -416,8 +455,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -438,7 +483,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -516,13 +566,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -532,9 +585,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -544,9 +599,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 831d1ba30672..5728c52d6b48 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,13 +292,16 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu vm_scale_set_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -276,11 +310,13 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,20 +360,25 @@ async def begin_start_extension_upgrade( # pylint: disable=inconsistent-return- :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_extension_upgrade_initial( + raw_result = await self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -347,8 +388,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -367,7 +414,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -379,13 +426,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -394,11 +444,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py index 36c561044b7d..193425c1155b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMExtensionsOperations: - """VirtualMachineScaleSetVMExtensionsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -51,17 +50,20 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -111,9 +115,9 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -141,17 +145,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -160,20 +167,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -192,17 +206,20 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -216,11 +233,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -248,9 +267,9 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -279,17 +298,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -298,20 +320,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -332,13 +361,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -349,11 +381,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,22 +435,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -426,8 +465,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -449,7 +494,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -467,13 +512,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -485,11 +533,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -518,7 +568,7 @@ async def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -534,13 +584,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -551,11 +604,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index 934875c92f3a..df2451da7dd9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -78,11 +80,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -132,17 +136,20 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -150,6 +157,8 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,13 +195,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -196,11 +214,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,21 +266,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -270,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -291,13 +322,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -307,11 +341,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,21 +394,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -382,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -401,17 +448,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -424,11 +474,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,9 +511,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -487,17 +539,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -505,20 +560,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -538,13 +600,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -554,11 +619,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -603,21 +670,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -627,8 +699,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -649,7 +727,7 @@ async def get( instance_id: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -658,21 +736,24 @@ async def get( :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. :type instance_id: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachineScaleSetVM, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -683,11 +764,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -715,7 +798,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -729,13 +812,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -745,11 +831,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -779,7 +867,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -803,13 +891,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -822,9 +913,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -837,9 +930,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -880,13 +975,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -897,11 +995,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -953,22 +1053,27 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -978,8 +1083,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -999,13 +1110,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1015,11 +1129,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1064,21 +1180,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1088,8 +1209,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1109,13 +1236,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1125,11 +1255,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1174,21 +1306,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1198,8 +1335,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1219,13 +1362,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1235,11 +1381,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1285,21 +1433,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1309,8 +1462,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1330,13 +1489,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1346,11 +1508,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1396,21 +1560,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1420,8 +1589,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1456,13 +1631,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -1472,11 +1650,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1498,18 +1678,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1522,11 +1705,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1555,11 +1740,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1570,7 +1755,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2019_12_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1587,16 +1772,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1604,20 +1792,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_sets_operations.py index 2d3e4030eb4d..aa21282f4b94 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -231,9 +250,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -409,7 +454,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -421,13 +466,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -436,11 +484,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -465,17 +515,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -490,11 +543,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -516,7 +571,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -543,23 +598,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -569,8 +629,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -587,17 +653,20 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -609,11 +678,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,7 +706,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -659,23 +730,28 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +761,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +787,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -717,13 +799,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -732,11 +817,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -762,7 +849,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -774,13 +861,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -789,9 +879,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -800,9 +892,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -839,7 +933,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -851,13 +945,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -865,9 +962,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -875,9 +974,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +1017,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -931,13 +1032,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -947,9 +1051,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -959,9 +1065,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1000,7 +1108,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1014,13 +1122,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1030,9 +1141,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1042,9 +1155,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1082,17 +1197,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1108,11 +1226,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1135,7 +1255,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1166,17 +1286,20 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -1184,6 +1307,8 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1193,8 +1318,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1211,17 +1342,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1236,11 +1370,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1262,7 +1398,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1287,23 +1423,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1313,8 +1454,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1331,17 +1478,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1356,11 +1506,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1382,7 +1534,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1407,23 +1559,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1433,8 +1590,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1451,17 +1614,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1476,11 +1642,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1502,7 +1670,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1528,23 +1696,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1554,8 +1727,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1572,17 +1751,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1597,11 +1779,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1623,7 +1807,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1651,23 +1835,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1677,8 +1866,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1695,17 +1890,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1717,11 +1915,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1743,7 +1943,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1767,23 +1967,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1793,8 +1998,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1811,17 +2022,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -1836,11 +2050,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1862,7 +2078,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -1888,23 +2104,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1914,8 +2135,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1932,17 +2159,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1957,11 +2187,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1983,7 +2215,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2009,23 +2241,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2035,8 +2272,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2056,7 +2299,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2072,13 +2315,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2019_12_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2088,11 +2334,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2118,7 +2366,7 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to true for a existing virtual machine scale set. @@ -2135,14 +2383,17 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret :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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] _json = self._serialize.body(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -2154,11 +2405,13 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2179,17 +2432,20 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] _json = self._serialize.body(parameters, 'OrchestrationServiceStateInput') @@ -2201,11 +2457,13 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2227,7 +2485,7 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> AsyncLROPoller[None]: """Changes ServiceState property for a given service. @@ -2250,23 +2508,28 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._set_orchestration_service_state_initial( + raw_result = await self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -2276,8 +2539,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_sizes_operations.py index a90e3a498dca..fa7add2cae65 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machines_operations.py index 06834f039a1c..45b75bd4b1c5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2019_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.compute.v2019_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -338,37 +364,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -385,17 +421,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -407,11 +446,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -441,9 +482,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -466,37 +507,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -515,13 +566,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -530,11 +584,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -576,20 +632,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -599,8 +660,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -620,28 +687,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -651,11 +721,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -682,7 +754,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -694,13 +766,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -709,11 +784,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -740,13 +817,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -755,11 +835,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -806,20 +888,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -829,8 +916,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -849,13 +942,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -864,11 +960,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -911,20 +1009,25 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -934,8 +1037,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -971,13 +1080,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -986,11 +1098,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1012,7 +1126,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1025,13 +1139,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1040,9 +1157,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1051,9 +1170,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1091,7 +1212,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1105,13 +1226,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1120,9 +1244,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1131,9 +1257,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1172,7 +1300,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1187,13 +1315,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1203,9 +1334,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1215,9 +1348,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1257,13 +1392,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1273,11 +1411,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1325,21 +1465,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1349,8 +1494,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1369,13 +1520,16 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -1384,11 +1538,13 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1430,20 +1586,25 @@ async def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._reapply_initial( + raw_result = await self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1453,8 +1614,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1473,13 +1640,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1488,11 +1658,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1534,20 +1706,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1557,8 +1734,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1577,13 +1760,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1592,11 +1778,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1638,20 +1826,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1661,8 +1854,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1681,13 +1880,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1696,11 +1898,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1742,20 +1946,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1765,8 +1974,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1783,17 +1998,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -1808,11 +2026,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1834,7 +2054,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -1858,23 +2078,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -1884,8 +2109,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1904,13 +2135,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1919,11 +2153,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1966,20 +2202,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1989,8 +2230,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2022,13 +2269,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2037,11 +2287,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2062,18 +2314,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2085,11 +2340,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2117,11 +2374,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2130,7 +2387,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2019_12_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2147,36 +2404,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/__init__.py index 87d536e74827..f91fc965af45 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/__init__.py @@ -270,7 +270,9 @@ VirtualMachineScaleSetSkuScaleType, VirtualMachineSizeTypes, ) - +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__ = [ 'AdditionalCapabilities', 'AdditionalUnattendContent', @@ -533,3 +535,5 @@ 'VirtualMachineScaleSetSkuScaleType', 'VirtualMachineSizeTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_compute_management_client_enums.py index 6b83e4a2c725..1644eac8000e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the aggregated replication status based on all the regional replication status flags. """ @@ -20,7 +19,7 @@ class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, En COMPLETED = "Completed" FAILED = "Failed" -class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. """ @@ -28,7 +27,7 @@ class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CLASSIC = "Classic" ALIGNED = "Aligned" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -39,7 +38,7 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the software license type that will be applied to the VMs deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` @@ -50,13 +49,13 @@ class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" -class DiffDiskOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk option for operating system disk. """ LOCAL = "Local" -class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskPlacement(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk placement for operating system disk. This property can be used by user in the request to choose the location i.e, cache disk or resource disk space for Ephemeral OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer @@ -69,7 +68,7 @@ class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CACHE_DISK = "CacheDisk" RESOURCE_DISK = "ResourceDisk" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -82,7 +81,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class GalleryApplicationVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryApplicationVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -93,7 +92,7 @@ class GalleryApplicationVersionPropertiesProvisioningState(with_metaclass(CaseIn DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImagePropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -104,7 +103,7 @@ class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnum DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImageVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -115,7 +114,7 @@ class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensit DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -126,7 +125,7 @@ class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, DELETING = "Deleting" MIGRATING = "Migrating" -class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite' """ @@ -134,28 +133,28 @@ class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class HyperVGenerationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type associated with a resource """ V1 = "V1" V2 = "V2" -class HyperVGenerationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type """ V1 = "V1" V2 = "V2" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -164,7 +163,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -173,7 +172,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -182,7 +181,7 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ @@ -191,20 +190,20 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: Specialized image. Contains already provisioned OS Disk. SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class OrchestrationServiceNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the service. """ AUTOMATIC_REPAIRS = "AutomaticRepairs" -class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current state of the service. """ @@ -212,14 +211,14 @@ class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enu RUNNING = "Running" SUSPENDED = "Suspended" -class OrchestrationServiceStateAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceStateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The action to be performed. """ RESUME = "Resume" SUSPEND = "Suspend" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -227,7 +226,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -236,7 +235,7 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the regional replication state. """ @@ -245,11 +244,11 @@ class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAILED = "Failed" -class ReplicationStatusTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): REPLICATION_STATUS = "ReplicationStatus" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -260,14 +259,14 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -276,7 +275,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -284,7 +283,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -292,7 +291,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type to be used to store the image. This property is not updatable. """ @@ -301,7 +300,7 @@ class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. StandardSSD_LRS uses Standard SSD. Premium_LRS uses Premium SSD. UltraSSD_LRS uses Ultra disk. @@ -316,7 +315,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_SSD_LRS = "StandardSSD_LRS" ULTRA_SSD_LRS = "UltraSSD_LRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -328,7 +327,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -336,7 +335,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -345,14 +344,14 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for the Azure Spot VM/VMSS """ DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for a standalone virtual machine or the virtual machines in the scale set. :code:`
`:code:`
` 'Low' enum will be deprecated in the future, please use 'Spot' as the enum to deploy Azure Spot VM/VMSS. @@ -362,20 +361,20 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E LOW = "Low" SPOT = "Spot" -class VirtualMachineScaleSetScaleInRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "Default" OLDEST_VM = "OldestVM" NEWEST_VM = "NewestVM" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. For more information about virtual machine sizes, see `Sizes for virtual machines `_. diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_models_py3.py index 1d03629165c0..d916e9f07b2a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AdditionalCapabilities(msrest.serialization.Model): @@ -56,7 +58,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2019_12_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -77,7 +79,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -90,7 +92,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2019_12_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -158,8 +160,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -461,11 +463,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -523,7 +525,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -605,11 +607,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -858,8 +860,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -870,7 +871,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -917,14 +918,14 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, to_be_detached: Optional[bool] = None, **kwargs ): @@ -944,8 +945,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -956,7 +956,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1115,7 +1115,7 @@ class DedicatedHost(Resource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1160,11 +1160,11 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1185,7 +1185,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostLicenseTypes """ @@ -1251,7 +1251,7 @@ class DedicatedHostAvailableCapacity(msrest.serialization.Model): def __init__( self, *, - allocatable_v_ms: Optional[List["DedicatedHostAllocatableVM"]] = None, + allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs ): """ @@ -1362,7 +1362,7 @@ class DedicatedHostGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHostGroup"], + value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs ): @@ -1459,8 +1459,8 @@ class DedicatedHostInstanceView(msrest.serialization.Model): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1500,7 +1500,7 @@ class DedicatedHostListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHost"], + value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs ): @@ -1537,7 +1537,7 @@ class DedicatedHostUpdate(UpdateResource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1574,7 +1574,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1590,7 +1590,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostLicenseTypes """ @@ -1622,7 +1622,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -1639,8 +1639,8 @@ def __init__( class DiffDiskSettings(msrest.serialization.Model): """Describes the parameters of ephemeral disk settings that can be specified for operating system disk. :code:`
`:code:`
` NOTE: The ephemeral disk settings can only be specified for managed disk. - :ivar option: Specifies the ephemeral disk settings for operating system disk. Possible values - include: "Local". + :ivar option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :vartype option: str or ~azure.mgmt.compute.v2019_12_01.models.DiffDiskOptions :ivar placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -1649,7 +1649,7 @@ class DiffDiskSettings(msrest.serialization.Model): Refer to VM size documentation for Windows VM at https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes to check which VM sizes - exposes a cache disk. Possible values include: "CacheDisk", "ResourceDisk". + exposes a cache disk. Known values are: "CacheDisk", "ResourceDisk". :vartype placement: str or ~azure.mgmt.compute.v2019_12_01.models.DiffDiskPlacement """ @@ -1661,13 +1661,13 @@ class DiffDiskSettings(msrest.serialization.Model): def __init__( self, *, - option: Optional[Union[str, "DiffDiskOptions"]] = None, - placement: Optional[Union[str, "DiffDiskPlacement"]] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, + placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, **kwargs ): """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. Possible - values include: "Local". + :keyword option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :paramtype option: str or ~azure.mgmt.compute.v2019_12_01.models.DiffDiskOptions :keyword placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -1676,7 +1676,7 @@ def __init__( Refer to VM size documentation for Windows VM at https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes to check which VM sizes - exposes a cache disk. Possible values include: "CacheDisk", "ResourceDisk". + exposes a cache disk. Known values are: "CacheDisk", "ResourceDisk". :paramtype placement: str or ~azure.mgmt.compute.v2019_12_01.models.DiffDiskPlacement """ super(DiffDiskSettings, self).__init__(**kwargs) @@ -1779,8 +1779,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -1822,8 +1822,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1859,8 +1859,8 @@ class EncryptionImages(msrest.serialization.Model): def __init__( self, *, - os_disk_image: Optional["OSDiskImageEncryption"] = None, - data_disk_images: Optional[List["DataDiskImageEncryption"]] = None, + os_disk_image: Optional["_models.OSDiskImageEncryption"] = None, + data_disk_images: Optional[List["_models.DataDiskImageEncryption"]] = None, **kwargs ): """ @@ -1897,8 +1897,8 @@ class Gallery(Resource): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2019_12_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_12_01.models.GalleryPropertiesProvisioningState """ @@ -1928,7 +1928,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, **kwargs ): """ @@ -1979,8 +1979,8 @@ class GalleryApplication(Resource): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes """ @@ -2015,7 +2015,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -2037,8 +2037,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes """ @@ -2075,7 +2075,7 @@ class GalleryApplicationList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplication"], + value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs ): @@ -2164,8 +2164,8 @@ class GalleryApplicationUpdate(UpdateResourceDefinition): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes """ @@ -2197,7 +2197,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -2217,8 +2217,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes """ @@ -2251,8 +2251,8 @@ class GalleryApplicationVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersionPropertiesProvisioningState :ivar replication_status: This is the replication status of the gallery Image Version. @@ -2284,7 +2284,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -2326,7 +2326,7 @@ class GalleryApplicationVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplicationVersion"], + value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs ): @@ -2363,7 +2363,7 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType """ @@ -2384,11 +2384,11 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, **kwargs ): """ @@ -2406,7 +2406,7 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType @@ -2443,7 +2443,7 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType :ivar source: Required. The source image from which the Image Version is going to be created. @@ -2474,13 +2474,13 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil def __init__( self, *, - source: "UserArtifactSource", - target_regions: Optional[List["TargetRegion"]] = None, + source: "_models.UserArtifactSource", + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - manage_actions: Optional["UserArtifactManage"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + manage_actions: Optional["_models.UserArtifactManage"] = None, enable_health_check: Optional[bool] = None, **kwargs ): @@ -2499,7 +2499,7 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType @@ -2533,8 +2533,8 @@ class GalleryApplicationVersionUpdate(UpdateResourceDefinition): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersionPropertiesProvisioningState :ivar replication_status: This is the replication status of the gallery Image Version. @@ -2563,7 +2563,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -2599,7 +2599,7 @@ class GalleryArtifactSource(msrest.serialization.Model): def __init__( self, *, - managed_image: "ManagedArtifact", + managed_image: "_models.ManagedArtifact", **kwargs ): """ @@ -2645,7 +2645,7 @@ class GalleryDiskImage(msrest.serialization.Model): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2019_12_01.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource @@ -2664,13 +2664,13 @@ class GalleryDiskImage(msrest.serialization.Model): def __init__( self, *, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2019_12_01.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource @@ -2691,7 +2691,7 @@ class GalleryDataDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2019_12_01.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource @@ -2717,13 +2717,13 @@ def __init__( self, *, lun: int, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2019_12_01.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource @@ -2792,15 +2792,15 @@ class GalleryImage(Resource): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemStateTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGeneration :ivar end_of_life_date: The end of life date of the gallery Image Definition. This property can be used for decommissioning purposes. This property is updatable. @@ -2815,8 +2815,8 @@ class GalleryImage(Resource): :ivar purchase_plan: Describes the gallery Image Definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2019_12_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_12_01.models.GalleryImagePropertiesProvisioningState """ @@ -2859,14 +2859,14 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, **kwargs ): """ @@ -2885,15 +2885,15 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemStateTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGeneration :keyword end_of_life_date: The end of life date of the gallery Image Definition. This property can be used for decommissioning purposes. This property is updatable. @@ -2996,7 +2996,7 @@ class GalleryImageList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImage"], + value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs ): @@ -3036,15 +3036,15 @@ class GalleryImageUpdate(UpdateResourceDefinition): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemStateTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGeneration :ivar end_of_life_date: The end of life date of the gallery Image Definition. This property can be used for decommissioning purposes. This property is updatable. @@ -3059,8 +3059,8 @@ class GalleryImageUpdate(UpdateResourceDefinition): :ivar purchase_plan: Describes the gallery Image Definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2019_12_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_12_01.models.GalleryImagePropertiesProvisioningState """ @@ -3100,14 +3100,14 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, **kwargs ): """ @@ -3124,15 +3124,15 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemStateTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGeneration :keyword end_of_life_date: The end of life date of the gallery Image Definition. This property can be used for decommissioning purposes. This property is updatable. @@ -3184,8 +3184,8 @@ class GalleryImageVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery Image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionPropertiesProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -3221,8 +3221,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["GalleryImageVersionStorageProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -3268,7 +3268,7 @@ class GalleryImageVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImageVersion"], + value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs ): @@ -3305,7 +3305,7 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType """ @@ -3326,11 +3326,11 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, **kwargs ): """ @@ -3348,7 +3348,7 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType @@ -3376,9 +3376,9 @@ class GalleryImageVersionStorageProfile(msrest.serialization.Model): def __init__( self, *, - source: Optional["GalleryArtifactVersionSource"] = None, - os_disk_image: Optional["GalleryOSDiskImage"] = None, - data_disk_images: Optional[List["GalleryDataDiskImage"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, + os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, + data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, **kwargs ): """ @@ -3411,8 +3411,8 @@ class GalleryImageVersionUpdate(UpdateResourceDefinition): :ivar publishing_profile: The publishing profile of a gallery Image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionPropertiesProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -3445,8 +3445,8 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["GalleryImageVersionStorageProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -3490,7 +3490,7 @@ class GalleryList(msrest.serialization.Model): def __init__( self, *, - value: List["Gallery"], + value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs ): @@ -3514,7 +3514,7 @@ class GalleryOSDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2019_12_01.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource @@ -3533,13 +3533,13 @@ class GalleryOSDiskImage(GalleryDiskImage): def __init__( self, *, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2019_12_01.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2019_12_01.models.GalleryArtifactVersionSource @@ -3565,8 +3565,8 @@ class GalleryUpdate(UpdateResourceDefinition): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2019_12_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2019_12_01.models.GalleryPropertiesProvisioningState """ @@ -3593,7 +3593,7 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, **kwargs ): """ @@ -3624,8 +3624,8 @@ class HardwareProfile(msrest.serialization.Model): :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -3670,7 +3670,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -3684,8 +3684,8 @@ def __init__( :code:`
`:code:`
` `List all available virtual machine sizes in a region `_ :code:`
`:code:`
` `List all available virtual machine sizes for resizing - `_. Possible - values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", + `_. Known + values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", "Standard_A4m_v2", @@ -3750,7 +3750,7 @@ class Image(Resource): :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Possible values include: "V1", "V2". + image. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationTypes """ @@ -3780,9 +3780,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -3795,7 +3795,7 @@ def __init__( :keyword storage_profile: Specifies the storage settings for the virtual machine disks. :paramtype storage_profile: ~azure.mgmt.compute.v2019_12_01.models.ImageStorageProfile :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Possible values include: "V1", "V2". + the image. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationTypes """ @@ -3818,16 +3818,15 @@ class ImageDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -3849,13 +3848,13 @@ class ImageDisk(msrest.serialization.Model): def __init__( self, *, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3868,16 +3867,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -3909,16 +3907,15 @@ class ImageDataDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -3950,13 +3947,13 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3969,16 +3966,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -4018,7 +4014,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -4048,16 +4044,15 @@ class ImageOSDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -4066,10 +4061,10 @@ class ImageOSDisk(ImageDisk): ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSetParameters :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemStateTypes """ @@ -4093,15 +4088,15 @@ class ImageOSDisk(ImageDisk): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -4114,16 +4109,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -4132,11 +4126,10 @@ def __init__( ~azure.mgmt.compute.v2019_12_01.models.DiskEncryptionSetParameters :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemStateTypes """ super(ImageOSDisk, self).__init__(snapshot=snapshot, managed_disk=managed_disk, blob_uri=blob_uri, caching=caching, disk_size_gb=disk_size_gb, storage_account_type=storage_account_type, disk_encryption_set=disk_encryption_set, **kwargs) @@ -4284,8 +4277,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -4324,7 +4317,7 @@ class ImageUpdate(UpdateResource): :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Possible values include: "V1", "V2". + image. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationTypes """ @@ -4345,9 +4338,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -4358,7 +4351,7 @@ def __init__( :keyword storage_profile: Specifies the storage settings for the virtual machine disks. :paramtype storage_profile: ~azure.mgmt.compute.v2019_12_01.models.ImageStorageProfile :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Possible values include: "V1", "V2". + the image. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationTypes """ @@ -4406,7 +4399,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2019_12_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -4428,7 +4421,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -4437,7 +4430,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2019_12_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -4479,7 +4472,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -4518,7 +4511,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -4557,7 +4550,7 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, provision_vm_agent: Optional[bool] = None, **kwargs ): @@ -4603,7 +4596,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -4757,8 +4750,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2019_12_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -4783,7 +4776,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -4799,8 +4792,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2019_12_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -4853,8 +4846,8 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -4873,16 +4866,16 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -4944,7 +4937,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -4962,11 +4955,9 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :ivar service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceNames - :ivar action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :ivar action: Required. The action to be performed. Known values are: "Resume", "Suspend". :vartype action: str or ~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceStateAction """ @@ -4983,17 +4974,15 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): def __init__( self, *, - service_name: Union[str, "OrchestrationServiceNames"], - action: Union[str, "OrchestrationServiceStateAction"], + service_name: Union[str, "_models.OrchestrationServiceNames"], + action: Union[str, "_models.OrchestrationServiceStateAction"], **kwargs ): """ - :keyword service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :keyword service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :paramtype service_name: str or ~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceNames - :keyword action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :keyword action: Required. The action to be performed. Known values are: "Resume", "Suspend". :paramtype action: str or ~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceStateAction """ @@ -5007,9 +4996,9 @@ class OrchestrationServiceSummary(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar service_name: The name of the service. Possible values include: "AutomaticRepairs". + :ivar service_name: The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceNames - :ivar service_state: The current state of the service. Possible values include: "NotRunning", + :ivar service_state: The current state of the service. Known values are: "NotRunning", "Running", "Suspended". :vartype service_state: str or ~azure.mgmt.compute.v2019_12_01.models.OrchestrationServiceState """ @@ -5042,8 +5031,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -5059,8 +5048,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -5074,7 +5062,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5105,24 +5093,24 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -5138,8 +5126,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -5153,7 +5140,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5181,8 +5168,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes """ @@ -5197,12 +5184,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -5328,9 +5315,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, require_guest_provision_signal: Optional[bool] = None, **kwargs @@ -5488,7 +5475,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -5535,8 +5522,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -5547,7 +5534,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroupType :keyword colocation_status: Describes colocation status of the Proximity Placement Group. @@ -5584,7 +5571,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -5689,8 +5676,8 @@ class RecommendedMachineConfiguration(msrest.serialization.Model): def __init__( self, *, - v_cp_us: Optional["ResourceRange"] = None, - memory: Optional["ResourceRange"] = None, + v_cp_us: Optional["_models.ResourceRange"] = None, + memory: Optional["_models.ResourceRange"] = None, **kwargs ): """ @@ -5744,7 +5731,7 @@ class RegionalReplicationStatus(msrest.serialization.Model): :ivar region: The region to which the gallery Image Version is being replicated to. :vartype region: str - :ivar state: This is the regional replication state. Possible values include: "Unknown", + :ivar state: This is the regional replication state. Known values are: "Unknown", "Replicating", "Completed", "Failed". :vartype state: str or ~azure.mgmt.compute.v2019_12_01.models.ReplicationState :ivar details: The details of the replication status. @@ -5786,8 +5773,7 @@ class ReplicationStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Possible values include: "Unknown", "InProgress", "Completed", - "Failed". + replication status flags. Known values are: "Unknown", "InProgress", "Completed", "Failed". :vartype aggregated_state: str or ~azure.mgmt.compute.v2019_12_01.models.AggregatedReplicationState :ivar summary: This is a summary of replication status for each region. @@ -5834,7 +5820,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_resource_name: Group query result by Resource Name. :vartype group_by_resource_name: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2019_12_01.models.IntervalInMins """ @@ -5861,7 +5847,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -5882,7 +5868,7 @@ def __init__( :keyword group_by_resource_name: Group query result by Resource Name. :paramtype group_by_resource_name: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2019_12_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, **kwargs) @@ -6083,13 +6069,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -6202,8 +6188,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -6232,7 +6217,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -6242,8 +6227,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -6267,8 +6251,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -6304,11 +6287,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -6316,8 +6299,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -6363,7 +6345,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -6444,7 +6426,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -6527,7 +6509,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -6566,7 +6548,7 @@ class ScaleInPolicy(msrest.serialization.Model): def __init__( self, *, - rules: Optional[List[Union[str, "VirtualMachineScaleSetScaleInRules"]]] = None, + rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, **kwargs ): """ @@ -6607,7 +6589,7 @@ class ScheduledEventsProfile(msrest.serialization.Model): def __init__( self, *, - terminate_notification_profile: Optional["TerminateNotificationProfile"] = None, + terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs ): """ @@ -6677,7 +6659,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -6872,7 +6854,7 @@ class SshPublicKeysGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["SshPublicKeyResource"], + value: List["_models.SshPublicKeyResource"], next_link: Optional[str] = None, **kwargs ): @@ -6954,9 +6936,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -7028,7 +7010,7 @@ def __init__( self, *, id: Optional[str] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -7053,7 +7035,7 @@ class TargetRegion(msrest.serialization.Model): region. This property is updatable. :vartype regional_replica_count: int :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS @@ -7077,8 +7059,8 @@ def __init__( *, name: str, regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - encryption: Optional["EncryptionImages"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + encryption: Optional["_models.EncryptionImages"] = None, **kwargs ): """ @@ -7088,7 +7070,7 @@ def __init__( region. This property is updatable. :paramtype regional_replica_count: int :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountType @@ -7254,7 +7236,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2019_12_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2019_12_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -7301,7 +7283,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2019_12_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -7341,8 +7323,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2019_12_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -7362,9 +7344,9 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["AutomaticOSUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, + automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, **kwargs ): """ @@ -7372,8 +7354,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2019_12_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -7427,7 +7409,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -7677,8 +7659,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -7790,14 +7772,13 @@ class VirtualMachine(Resource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -7869,22 +7850,22 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -7946,15 +7927,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -8019,8 +7999,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -8216,7 +8196,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -8281,7 +8261,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -8418,8 +8398,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -8456,7 +8436,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -8588,8 +8568,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2019_12_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -8613,15 +8593,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2019_12_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -8717,8 +8697,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2019_12_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: "V1", - "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationTypes """ @@ -8747,11 +8726,11 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, + automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -8776,8 +8755,7 @@ def __init__( image. :paramtype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2019_12_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: - "V1", "V2". + :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationTypes """ @@ -8802,8 +8780,8 @@ class VirtualMachineInstanceView(msrest.serialization.Model): :vartype os_name: str :ivar os_version: The version of Operating System running on the virtual machine. :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationType :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. :vartype rdp_thumb_print: str @@ -8850,14 +8828,14 @@ def __init__( computer_name: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationType"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -8872,7 +8850,7 @@ def __init__( :keyword os_version: The version of Operating System running on the virtual machine. :paramtype os_version: str :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2019_12_01.models.HyperVGenerationType :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. @@ -8935,7 +8913,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -9088,21 +9066,21 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, **kwargs ): """ @@ -9195,14 +9173,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -9242,12 +9219,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -9262,14 +9239,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -9435,7 +9411,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -9466,7 +9442,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, **kwargs ): """ @@ -9602,7 +9578,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2019_12_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine @@ -9627,15 +9603,15 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2019_12_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual @@ -9718,7 +9694,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -9779,7 +9755,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2019_12_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -9823,14 +9799,14 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -9848,7 +9824,7 @@ def __init__( ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2019_12_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -9940,7 +9916,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -9981,7 +9957,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -10021,7 +9997,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -10061,7 +10037,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -10082,8 +10058,8 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can - only be used with data disks, it cannot be used with OS Disk. Possible values include: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", + "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -10100,14 +10076,14 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS - can only be used with data disks, it cannot be used with OS Disk. Possible values include: + can only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2019_12_01.models.StorageAccountTypes @@ -10170,9 +10146,9 @@ def __init__( id: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -10253,8 +10229,8 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -10281,8 +10257,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -10291,8 +10266,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -10303,8 +10278,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk @@ -10336,16 +10311,16 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -10354,8 +10329,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -10364,8 +10338,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2019_12_01.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -10377,7 +10351,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2019_12_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2019_12_01.models.VirtualHardDisk @@ -10476,9 +10450,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -10565,7 +10539,7 @@ class VirtualMachineScaleSetPublicIPAddressConfiguration(msrest.serialization.Mo :vartype public_ip_prefix: ~azure.mgmt.compute.v2019_12_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2019_12_01.models.IPVersion """ @@ -10587,10 +10561,10 @@ def __init__( *, name: str, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersion"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, **kwargs ): """ @@ -10607,7 +10581,7 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2019_12_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2019_12_01.models.IPVersion """ super(VirtualMachineScaleSetPublicIPAddressConfiguration, self).__init__(**kwargs) @@ -10765,8 +10739,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -10828,9 +10801,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -10921,18 +10894,18 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - proximity_placement_group: Optional["SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -11010,7 +10983,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2019_12_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -11044,14 +11017,14 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -11069,7 +11042,7 @@ def __init__( ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2019_12_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -11140,9 +11113,9 @@ def __init__( name: Optional[str] = None, primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -11197,8 +11170,8 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, **kwargs ): """ @@ -11218,7 +11191,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -11250,16 +11223,16 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2019_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -11311,9 +11284,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -11356,7 +11329,7 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, **kwargs ): """ @@ -11395,9 +11368,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -11456,14 +11429,14 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, **kwargs ): """ @@ -11638,17 +11611,17 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - network_profile_configuration: Optional["VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, - protection_policy: Optional["VirtualMachineScaleSetVMProtectionPolicy"] = None, + protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, **kwargs ): """ @@ -11881,12 +11854,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -11956,7 +11929,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -11987,7 +11960,7 @@ class VirtualMachineScaleSetVMNetworkProfileConfiguration(msrest.serialization.M def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -12029,15 +12002,14 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -12064,16 +12036,16 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, **kwargs ): """ @@ -12104,15 +12076,14 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -12251,7 +12222,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -12353,14 +12324,13 @@ class VirtualMachineUpdate(UpdateResource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -12421,22 +12391,22 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, **kwargs ): @@ -12496,15 +12466,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2019_12_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -12618,8 +12587,8 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -12668,7 +12637,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -12683,7 +12652,7 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :vartype protocol: str or ~azure.mgmt.compute.v2019_12_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as @@ -12704,13 +12673,13 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2019_12_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/__init__.py index 7d409a1b87d4..c1c277fa7bc6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/__init__.py @@ -32,6 +32,9 @@ from ._gallery_applications_operations import GalleryApplicationsOperations from ._gallery_application_versions_operations import GalleryApplicationVersionsOperations +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', 'AvailabilitySetsOperations', @@ -59,3 +62,5 @@ 'GalleryApplicationsOperations', 'GalleryApplicationVersionsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_availability_sets_operations.py index ebeef587bc25..4eb264343938 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +190,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -199,20 +205,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -235,18 +242,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -257,9 +262,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -271,51 +279,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -329,14 +333,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -348,11 +355,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -378,9 +387,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -394,14 +403,17 @@ def update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -413,11 +425,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,13 +470,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -471,11 +488,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -498,7 +517,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -510,13 +529,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -525,11 +547,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -555,7 +579,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -568,13 +592,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -583,9 +610,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +623,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -634,7 +665,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -646,13 +677,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +695,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -672,9 +708,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -713,7 +751,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -728,13 +766,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -756,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_dedicated_host_groups_operations.py index 7a37a5662c36..02a486c2c089 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_dedicated_host_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -186,9 +189,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -199,18 +205,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -219,9 +223,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") path_format_arguments = { @@ -231,51 +238,47 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostGroupsOperations(object): - """DedicatedHostGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -291,14 +294,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -310,11 +316,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -344,9 +352,9 @@ def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -360,14 +368,17 @@ def update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -379,11 +390,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -422,13 +435,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -437,11 +453,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -464,7 +482,7 @@ def get( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -476,13 +494,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -491,11 +512,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -521,7 +544,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -534,13 +557,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -549,9 +575,11 @@ def prepare_request(next_link=None): 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: @@ -560,9 +588,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -599,7 +629,7 @@ def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -610,13 +640,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -624,9 +657,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -634,9 +669,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_dedicated_hosts_operations.py index f4cf236c5eb2..c9839caf999f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHost] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_by_host_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_by_host_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostsOperations(object): - """DedicatedHostsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -341,17 +348,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -359,20 +369,27 @@ def begin_create_or_update( 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('DedicatedHost', 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( @@ -390,17 +407,20 @@ def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -413,11 +433,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -444,9 +466,9 @@ def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -470,17 +492,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -488,20 +513,27 @@ def begin_update( 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('DedicatedHost', 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( @@ -521,13 +553,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements host_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -537,11 +572,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -586,21 +623,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -610,8 +652,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -632,7 +680,7 @@ def get( host_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -641,21 +689,24 @@ def get( :type host_group_name: str :param host_name: The name of the dedicated host. :type host_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedHost, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_12_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -666,11 +717,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +750,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostListResult"]: + ) -> Iterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -712,13 +765,16 @@ def list_by_host_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -728,9 +784,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -740,9 +798,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_galleries_operations.py index 4ab07585af42..27e7ddaa5420 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.Gallery] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") path_format_arguments = { @@ -239,58 +247,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleriesOperations(object): - """GalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -302,11 +309,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -339,9 +348,9 @@ def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -363,37 +372,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -410,17 +429,20 @@ def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Gallery] _json = self._serialize.body(gallery, 'GalleryUpdate') @@ -432,11 +454,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -462,9 +486,9 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -486,37 +510,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -535,7 +569,7 @@ def get( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -547,13 +581,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -562,11 +599,13 @@ def get( gallery_name=gallery_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,13 +632,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -608,11 +650,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -654,20 +698,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -677,8 +726,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -696,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -706,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -721,9 +779,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -732,9 +792,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -771,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -779,13 +841,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -793,9 +858,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -803,9 +870,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_application_versions_operations.py index e3a8de0a1489..de414456dabb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +137,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +156,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -177,9 +180,12 @@ def build_delete_request_initial( gallery_application_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +199,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -216,9 +220,12 @@ def build_list_by_gallery_application_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -231,42 +238,38 @@ def build_list_by_gallery_application_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationVersionsOperations(object): - """GalleryApplicationVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -274,17 +277,20 @@ def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -298,11 +304,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -373,17 +381,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -392,20 +403,27 @@ def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -424,17 +442,20 @@ def _update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersionUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,9 +503,9 @@ def begin_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -516,17 +539,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -535,20 +561,27 @@ def begin_update( 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('GalleryApplicationVersion', 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( @@ -570,7 +603,7 @@ def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -591,13 +624,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -609,11 +645,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -642,13 +680,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -659,11 +700,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -714,22 +757,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -739,8 +787,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -760,7 +814,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationVersionList"]: + ) -> Iterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -778,13 +832,16 @@ def list_by_gallery_application( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +852,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -808,9 +867,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_applications_operations.py index b96427e64f5e..9994f34012ad 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplication] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_get_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -181,18 +187,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +207,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications") # pylint: disable=line-too-long path_format_arguments = { @@ -217,59 +224,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationsOperations(object): - """GalleryApplicationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -282,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -320,9 +328,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -351,17 +359,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -369,20 +380,27 @@ def begin_create_or_update( 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('GalleryApplication', 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( @@ -400,17 +418,20 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplicationUpdate') @@ -423,11 +444,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -454,9 +477,9 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -484,17 +507,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -502,20 +528,27 @@ def begin_update( 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('GalleryApplication', 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( @@ -535,7 +568,7 @@ def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -551,13 +584,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -567,11 +603,13 @@ def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -599,13 +637,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -615,11 +656,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -665,21 +708,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -689,8 +737,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -709,7 +763,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationList"]: + ) -> Iterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -724,13 +778,16 @@ def list_by_gallery( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -740,9 +797,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -752,9 +811,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_image_versions_operations.py index 55a801150d95..bd5addbd9167 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +137,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +156,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -177,9 +180,12 @@ def build_delete_request_initial( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +199,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -216,9 +220,12 @@ def build_list_by_gallery_image_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -231,42 +238,38 @@ def build_list_by_gallery_image_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImageVersionsOperations(object): - """GalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -274,17 +277,20 @@ def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -298,11 +304,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Create or update a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -372,17 +380,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -423,17 +441,20 @@ def _update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersionUpdate') @@ -447,11 +468,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -479,9 +502,9 @@ def begin_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Update a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -514,17 +537,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -533,20 +559,27 @@ def begin_update( 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('GalleryImageVersion', 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( @@ -568,7 +601,7 @@ def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery Image Version. :param resource_group_name: The name of the resource group. @@ -588,13 +621,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -606,11 +642,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -639,13 +677,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -656,11 +697,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -710,22 +753,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -735,8 +783,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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,7 +810,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageVersionList"]: + ) -> Iterable[_models.GalleryImageVersionList]: """List gallery Image Versions in a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -774,13 +828,16 @@ def list_by_gallery_image( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -791,9 +848,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -804,9 +863,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_images_operations.py index 3e8cb4304b0d..cd7099ef5d06 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImage] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -181,18 +187,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +207,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images") # pylint: disable=line-too-long path_format_arguments = { @@ -217,59 +224,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImagesOperations(object): - """GalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -282,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -320,9 +328,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Create or update a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -349,17 +357,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -367,20 +378,27 @@ def begin_create_or_update( 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('GalleryImage', 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( @@ -398,17 +416,20 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImageUpdate') @@ -421,11 +442,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +475,9 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Update a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -481,17 +504,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -499,20 +525,27 @@ def begin_update( 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('GalleryImage', 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( @@ -532,7 +565,7 @@ def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery Image Definition. :param resource_group_name: The name of the resource group. @@ -547,13 +580,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -563,11 +599,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,13 +633,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -611,11 +652,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -661,21 +704,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +733,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +759,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageList"]: + ) -> Iterable[_models.GalleryImageList]: """List gallery Image Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -718,13 +772,16 @@ def list_by_gallery( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -734,9 +791,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -746,9 +805,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_images_operations.py index 74af645c3e3f..8bcea19a5f2b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -155,9 +157,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +174,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -192,9 +195,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -205,18 +211,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +229,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -237,58 +244,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -300,11 +306,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -334,9 +342,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -357,37 +365,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -404,17 +422,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -426,11 +447,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -460,9 +483,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -483,37 +506,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -532,13 +565,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -547,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,20 +631,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -616,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -637,7 +686,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -651,13 +700,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -667,11 +719,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -707,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -722,9 +779,11 @@ def prepare_request(next_link=None): 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: @@ -733,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -772,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -781,13 +842,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -805,9 +871,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_log_analytics_operations.py index 101c93dfdec9..797a4e88e005 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_operations.py index fde8c8f2bcf7..17673cfdf2d3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_proximity_placement_groups_operations.py index d6924d7ee9d8..f51297eda600 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( include_colocation_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +172,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if include_colocation_status is not None: - _query_parameters['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -189,9 +192,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -235,51 +242,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -293,14 +296,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -312,11 +318,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -346,9 +354,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -362,14 +370,17 @@ def update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -381,11 +392,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -424,13 +437,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -439,11 +455,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -467,7 +485,7 @@ def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -482,13 +500,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -498,11 +519,13 @@ def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +550,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -537,13 +560,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -551,9 +577,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -561,9 +589,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -601,7 +631,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -613,13 +643,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -628,9 +661,11 @@ def prepare_request(next_link=None): 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: @@ -639,9 +674,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_ssh_public_keys_operations.py index 6c29f76a2d0e..49c6fa994746 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_ssh_public_keys_operations.py @@ -16,12 +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 .. 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,9 +31,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") path_format_arguments = { @@ -43,18 +46,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -64,9 +65,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys") # pylint: disable=line-too-long path_format_arguments = { @@ -77,18 +81,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -98,14 +100,17 @@ def build_create_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -117,20 +122,18 @@ def build_create_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -142,14 +145,17 @@ def build_update_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyUpdateResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -161,20 +167,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -187,8 +191,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -200,13 +205,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -217,9 +221,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -231,18 +238,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -253,9 +258,12 @@ def build_generate_key_pair_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair") # pylint: disable=line-too-long path_format_arguments = { @@ -267,48 +275,44 @@ def build_generate_key_pair_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class SshPublicKeysOperations(object): - """SshPublicKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -319,13 +323,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -333,9 +340,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -343,9 +352,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -383,7 +394,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -396,13 +407,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -411,9 +425,11 @@ def prepare_request(next_link=None): 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: @@ -422,9 +438,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -462,9 +480,9 @@ def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -478,14 +496,17 @@ def create( :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -497,11 +518,13 @@ def create( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -531,9 +554,9 @@ def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -547,14 +570,17 @@ def update( :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -566,11 +592,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -609,13 +637,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -624,11 +655,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -651,7 +684,7 @@ def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -663,13 +696,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -678,11 +714,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -709,7 +747,7 @@ def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -723,13 +761,16 @@ def generate_key_pair( :rtype: ~azure.mgmt.compute.v2019_12_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -738,11 +779,13 @@ def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_usage_operations.py index 02a0c3486901..537916b99eff 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_extension_images_operations.py index 497f521be962..6d0161d969e4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_extensions_operations.py index f301a40d42f4..4782c31db068 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,8 +129,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -141,13 +144,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -161,9 +163,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -176,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -202,9 +205,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -216,61 +222,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -283,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -318,9 +325,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -347,17 +354,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -365,20 +375,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -396,17 +413,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -419,11 +439,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,9 +472,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -479,17 +501,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -497,20 +522,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -530,13 +562,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -546,11 +581,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,21 +632,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -619,8 +661,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -641,7 +689,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -657,13 +705,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -674,11 +725,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -706,7 +759,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -720,13 +773,16 @@ def list( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -736,11 +792,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_images_operations.py index c61ab4fb7a9c..8a6a9096d139 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_run_commands_operations.py index 036dbdf22db8..99215287653a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_run_commands_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -44,18 +48,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -66,9 +68,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -80,49 +85,45 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -134,13 +135,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -149,9 +153,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -160,9 +166,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -201,7 +209,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -213,13 +221,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -228,11 +239,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_extensions_operations.py index 261de3054a96..0acc1eb9c5f6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -345,17 +352,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -363,20 +373,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -394,17 +411,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -417,11 +437,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +474,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -481,17 +503,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -499,20 +524,27 @@ def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -532,13 +564,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -548,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -597,21 +634,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -621,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -643,7 +691,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -659,13 +707,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -676,11 +727,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -707,7 +760,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -721,13 +774,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -737,9 +793,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -749,9 +807,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index e31658515ec6..e14ae31bfdc4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,8 +34,9 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -46,13 +48,12 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -63,8 +64,9 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -76,13 +78,12 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -93,8 +94,9 @@ def build_start_extension_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -106,13 +108,12 @@ def build_start_extension_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -123,9 +124,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -137,42 +141,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -180,13 +180,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -195,11 +198,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,20 +246,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -264,8 +274,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -284,13 +300,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -299,11 +318,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,20 +368,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -370,8 +396,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -390,13 +422,16 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -405,11 +440,13 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -453,20 +490,25 @@ def begin_start_extension_upgrade( # pylint: disable=inconsistent-return-statem :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_extension_upgrade_initial( + raw_result = self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -476,8 +518,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -496,7 +544,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -508,13 +556,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2019_12_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -523,11 +574,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py index f15de2bd668f..2ab053081f73 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -56,20 +59,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -83,14 +84,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -104,20 +108,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -132,9 +134,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -148,18 +153,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -174,9 +177,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -190,20 +196,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -217,9 +221,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -232,44 +239,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMExtensionsOperations(object): - """VirtualMachineScaleSetVMExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -277,17 +280,20 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -301,11 +307,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -367,17 +375,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -386,20 +397,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -418,17 +436,20 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -442,11 +463,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -474,9 +497,9 @@ def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -505,17 +528,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -524,20 +550,27 @@ def begin_update( 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('VirtualMachineExtension', 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 +591,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -575,11 +611,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -627,22 +665,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -652,8 +695,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -675,7 +724,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -693,13 +742,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -711,11 +763,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -744,7 +798,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -760,13 +814,16 @@ def list( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -777,11 +834,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_vms_operations.py index b298df2389ba..db6fdccb2540 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,13 +35,15 @@ def build_reimage_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -54,19 +56,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,8 +80,9 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -94,13 +95,12 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -112,8 +112,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -126,13 +127,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -143,14 +143,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -163,20 +166,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -190,8 +191,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -204,13 +206,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -224,9 +225,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -239,20 +243,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -264,9 +266,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -279,18 +284,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -305,9 +308,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -319,24 +325,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -350,8 +354,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -364,15 +369,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -384,8 +388,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -398,13 +403,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -416,8 +420,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -430,13 +435,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -448,8 +452,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -462,13 +467,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -480,8 +484,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -494,13 +499,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -512,8 +516,9 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -526,13 +531,12 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -543,14 +547,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -563,63 +570,62 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -635,11 +641,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -662,7 +670,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -689,17 +697,20 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -707,6 +718,8 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -716,8 +729,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -737,13 +756,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -753,11 +775,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -803,21 +827,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -827,8 +856,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -848,13 +883,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -864,11 +902,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -915,21 +955,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -939,8 +984,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -958,17 +1009,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -981,11 +1035,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1016,9 +1072,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1044,17 +1100,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1062,20 +1121,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1095,13 +1161,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1111,11 +1180,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1160,21 +1231,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1184,8 +1260,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1206,7 +1288,7 @@ def get( instance_id: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1215,21 +1297,24 @@ def get( :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. :type instance_id: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachineScaleSetVM, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1240,11 +1325,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1272,7 +1359,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1286,13 +1373,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1302,11 +1392,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1336,7 +1428,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1360,13 +1452,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1379,9 +1474,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1394,9 +1491,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1437,13 +1536,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1454,11 +1556,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1510,22 +1614,27 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1535,8 +1644,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1556,13 +1671,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1572,11 +1690,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1621,21 +1741,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1645,8 +1770,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1666,13 +1797,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1682,11 +1816,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1731,21 +1867,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1755,8 +1896,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1776,13 +1923,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1792,11 +1942,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1842,21 +1994,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1866,8 +2023,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1887,13 +2050,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1903,11 +2069,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1953,21 +2121,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1977,8 +2150,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2013,13 +2192,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2029,11 +2211,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2055,18 +2239,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2079,11 +2266,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2112,11 +2301,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2127,7 +2316,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2019_12_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2143,16 +2332,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2160,20 +2352,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_sets_operations.py index c253d123eda0..21c96150a182 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,18 +172,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -188,13 +191,15 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -206,19 +211,17 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -230,13 +233,15 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -248,19 +253,17 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -273,9 +276,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -287,18 +293,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -308,9 +312,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -321,18 +328,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -341,9 +346,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -353,18 +361,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -375,9 +381,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -389,18 +398,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -411,9 +418,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -425,18 +435,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -446,14 +454,16 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -465,21 +475,19 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -491,13 +499,15 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -509,19 +519,17 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -533,13 +541,15 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -551,19 +561,17 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -575,13 +583,15 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -593,19 +603,17 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -617,13 +625,15 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -635,19 +645,17 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -659,13 +667,15 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -677,19 +687,17 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -701,13 +709,15 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -719,19 +729,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -743,13 +751,15 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -761,19 +771,17 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -788,9 +796,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( platform_update_domain: int, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -802,19 +813,17 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -824,13 +833,15 @@ def build_convert_to_single_placement_group_request( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VMScaleSetConvertToSinglePlacementGroupInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup") # pylint: disable=line-too-long path_format_arguments = { @@ -842,19 +853,17 @@ def build_convert_to_single_placement_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -866,13 +875,15 @@ def build_set_orchestration_service_state_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.OrchestrationServiceStateInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState") # pylint: disable=line-too-long path_format_arguments = { @@ -884,61 +895,60 @@ def build_set_orchestration_service_state_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -950,11 +960,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -984,9 +996,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1009,37 +1021,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1056,17 +1078,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -1078,11 +1103,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1108,9 +1135,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1133,37 +1160,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1182,13 +1219,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1197,11 +1237,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1243,20 +1285,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1266,8 +1313,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1286,7 +1339,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1298,13 +1351,16 @@ def get( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1313,11 +1369,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1342,17 +1400,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1367,11 +1428,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1393,7 +1456,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1420,23 +1483,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1446,8 +1514,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1464,17 +1538,20 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1486,11 +1563,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1512,7 +1591,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -1536,23 +1615,28 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1562,8 +1646,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1582,7 +1672,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1594,13 +1684,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1609,11 +1702,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1639,7 +1734,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1651,13 +1746,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1666,9 +1764,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1677,9 +1777,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1716,7 +1818,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1728,13 +1830,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1742,9 +1847,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1752,9 +1859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1793,7 +1902,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1808,13 +1917,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1824,9 +1936,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1836,9 +1950,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1877,7 +1993,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1891,13 +2007,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1907,9 +2026,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1919,9 +2040,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1959,17 +2082,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1985,11 +2111,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2012,7 +2140,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -2043,17 +2171,20 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -2061,6 +2192,8 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2070,8 +2203,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2088,17 +2227,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2113,11 +2255,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2139,7 +2283,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2164,23 +2308,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2190,8 +2339,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2208,17 +2363,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2233,11 +2391,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2259,7 +2419,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2284,23 +2444,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2310,8 +2475,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2328,17 +2499,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2353,11 +2527,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2379,7 +2555,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2405,23 +2581,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2431,8 +2612,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2449,17 +2636,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2474,11 +2664,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2500,7 +2692,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2528,23 +2720,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2554,8 +2751,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2572,17 +2775,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2594,11 +2800,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2620,7 +2828,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2644,23 +2852,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2670,8 +2883,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2688,17 +2907,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -2713,11 +2935,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2739,7 +2963,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -2765,23 +2989,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2791,8 +3020,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2809,17 +3044,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2834,11 +3072,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2860,7 +3100,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2886,23 +3126,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2912,8 +3157,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2933,7 +3184,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2949,13 +3200,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2019_12_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2965,11 +3219,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2995,7 +3251,7 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to true for a existing virtual machine scale set. @@ -3012,14 +3268,17 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st :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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] _json = self._serialize.body(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -3031,11 +3290,13 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3056,17 +3317,20 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] _json = self._serialize.body(parameters, 'OrchestrationServiceStateInput') @@ -3078,11 +3342,13 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3104,7 +3370,7 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> LROPoller[None]: """Changes ServiceState property for a given service. @@ -3127,23 +3393,28 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._set_orchestration_service_state_initial( + raw_result = self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -3153,8 +3424,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_sizes_operations.py index e5b4d355ee10..861a3437712f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -99,13 +99,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machines_operations.py index e1714eed6022..2127ad95e8c8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -201,8 +205,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -214,13 +219,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -233,9 +237,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -247,20 +254,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -271,9 +276,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -285,18 +293,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -307,8 +313,9 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -320,13 +327,12 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -337,8 +343,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -350,13 +357,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -367,8 +373,9 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -380,13 +387,12 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -396,9 +402,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -409,18 +418,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -431,9 +438,12 @@ def build_list_all_request( status_only: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -443,20 +453,18 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 status_only is not None: - _query_parameters['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') + _params['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -467,9 +475,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -481,18 +492,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -505,8 +514,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -518,15 +528,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -537,9 +546,12 @@ def build_reapply_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply") # pylint: disable=line-too-long path_format_arguments = { @@ -551,18 +563,16 @@ def build_reapply_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -573,8 +583,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -586,13 +597,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -603,8 +613,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -616,13 +627,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -633,8 +643,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -646,13 +657,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -662,13 +672,15 @@ def build_reimage_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -680,19 +692,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -705,8 +715,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -718,13 +729,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -735,8 +745,9 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -748,13 +759,12 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -764,14 +774,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -783,53 +796,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2019_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.compute.v2019_12_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -841,13 +850,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -856,9 +868,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -867,9 +881,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -906,17 +922,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -928,11 +947,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -960,9 +981,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -986,37 +1007,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -1033,17 +1064,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -1055,11 +1089,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1089,9 +1125,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -1114,37 +1150,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1161,17 +1207,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1183,11 +1232,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1217,9 +1268,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1241,37 +1292,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1290,13 +1351,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1305,11 +1369,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1351,20 +1417,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1374,8 +1445,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1395,28 +1472,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1426,11 +1506,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1457,7 +1539,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1469,13 +1551,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2019_12_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1484,11 +1569,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1515,13 +1602,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1530,11 +1620,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1581,20 +1673,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1604,8 +1701,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1624,13 +1727,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -1639,11 +1745,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1686,20 +1794,25 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1709,8 +1822,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1746,13 +1865,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1761,11 +1883,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1787,7 +1911,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1800,13 +1924,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1815,9 +1942,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1826,9 +1955,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1866,7 +1997,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1880,13 +2011,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1895,9 +2029,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1906,9 +2042,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1947,7 +2085,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1962,13 +2100,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2019_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1978,9 +2119,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1990,9 +2133,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2032,13 +2177,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -2048,11 +2196,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2100,21 +2250,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2124,8 +2279,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2144,13 +2305,16 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -2159,11 +2323,13 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2205,20 +2371,25 @@ def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._reapply_initial( + raw_result = self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2228,8 +2399,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2248,13 +2425,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2263,11 +2443,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2309,20 +2491,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2332,8 +2519,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2352,13 +2545,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2367,11 +2563,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2413,20 +2611,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2436,8 +2639,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2456,13 +2665,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2471,11 +2683,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2517,20 +2731,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2540,8 +2759,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2558,17 +2783,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -2583,11 +2811,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2609,7 +2839,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -2633,23 +2863,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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[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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -2659,8 +2894,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2679,13 +2920,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2694,11 +2938,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2741,20 +2987,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2764,8 +3015,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2797,13 +3054,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2812,11 +3072,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2837,18 +3099,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2860,11 +3125,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2892,11 +3159,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2905,7 +3172,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2019_12_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2921,36 +3188,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2019_12_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2019-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_compute_management_client.py index d298df9c334c..838602b06c28 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_compute_management_client.py @@ -62,10 +62,18 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/_compute_management_client.py index 20a390566679..19c7ad497c51 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/_compute_management_client.py @@ -62,10 +62,18 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/__init__.py index 22cffb20eb1d..057394001370 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/__init__.py @@ -11,9 +11,14 @@ from ._disk_encryption_sets_operations import DiskEncryptionSetsOperations from ._disk_accesses_operations import DiskAccessesOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', 'DiskEncryptionSetsOperations', 'DiskAccessesOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_disk_accesses_operations.py index ca416373840d..b83735a4ddcd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskAccessesOperations: - """DiskAccessesOperations async operations. - - You 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.compute.v2020_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_05_01.aio.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_05_01.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -340,11 +372,13 @@ async def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -626,7 +690,7 @@ async def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -640,13 +704,16 @@ async def get_private_link_resources( :rtype: ~azure.mgmt.compute.v2020_05_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', "2020-05-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -655,11 +722,13 @@ async def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_disk_encryption_sets_operations.py index ab8a50a983e7..6f4aab14bed7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskEncryptionSetsOperations: - """DiskEncryptionSetsOperations async operations. - - You 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.compute.v2020_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_05_01.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -238,9 +257,9 @@ async def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -266,37 +285,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -315,7 +344,7 @@ async def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -329,13 +358,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -344,11 +376,13 @@ async def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -375,13 +409,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -390,11 +427,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,20 +477,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -461,8 +505,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -480,7 +530,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -492,13 +542,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -507,9 +560,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -518,9 +573,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -557,7 +614,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -567,13 +624,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -581,9 +641,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -591,9 +653,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_disks_operations.py index c5ce393de0e7..cfb61e14b6bf 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2020_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_05_01.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_05_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_snapshots_operations.py index e6f52e3bfaef..a3ce5d23e1eb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2020_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_05_01.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_05_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_05_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_05_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_05_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/__init__.py index 3a8b16641e74..3bf535d97619 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/__init__.py @@ -57,7 +57,9 @@ PrivateEndpointServiceConnectionStatus, SnapshotStorageAccountTypes, ) - +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__ = [ 'AccessUri', 'ApiError', @@ -107,3 +109,5 @@ 'PrivateEndpointServiceConnectionStatus', 'SnapshotStorageAccountTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_compute_management_client_enums.py index de0d8f572589..e09da6104772 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_compute_management_client_enums.py @@ -7,17 +7,16 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" WRITE = "Write" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -40,13 +39,13 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the disk. UPLOAD = "Upload" -class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported. """ SYSTEM_ASSIGNED = "SystemAssigned" -class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the disk. """ @@ -63,7 +62,7 @@ class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: A disk is created for upload and a write token has been issued for uploading to it. ACTIVE_UPLOAD = "ActiveUpload" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -78,7 +77,7 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: databases (for example, SQL, Oracle), and other transaction-heavy workloads. ULTRA_SSD_LRS = "UltraSSD_LRS" -class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -92,14 +91,14 @@ class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the other key is Platform managed. ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Policy for accessing the disk via network. """ @@ -110,14 +109,14 @@ class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The disk cannot be exported. DENY_ALL = "DenyAll" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -126,7 +125,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. """ @@ -134,7 +133,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_models_py3.py index 73241c8f0bd0..136aa76462ac 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -66,8 +68,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -139,8 +141,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :vartype create_option: str or ~azure.mgmt.compute.v2020_05_01.models.DiskCreateOption :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -185,10 +187,10 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, - gallery_image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, + gallery_image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, upload_size_bytes: Optional[int] = None, @@ -196,7 +198,7 @@ def __init__( ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :paramtype create_option: str or ~azure.mgmt.compute.v2020_05_01.models.DiskCreateOption :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -314,10 +316,10 @@ class Disk(Resource): :vartype zones: list[str] :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_05_01.models.HyperVGeneration :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -351,7 +353,7 @@ class Disk(Resource): mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. :vartype disk_m_bps_read_only: long - :ivar disk_state: The state of the disk. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", "Reserved", "ActiveSAS", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2020_05_01.models.DiskState :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed @@ -363,8 +365,8 @@ class Disk(Resource): :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should be set to a value greater than one for disks to allow attaching them to multiple VMs. :vartype share_info: list[~azure.mgmt.compute.v2020_05_01.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -422,20 +424,20 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - creation_data: Optional["CreationData"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, **kwargs ): @@ -449,10 +451,10 @@ def __init__( :paramtype sku: ~azure.mgmt.compute.v2020_05_01.models.DiskSku :keyword zones: The Logical zone list for Disk. :paramtype zones: list[str] - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_05_01.models.HyperVGeneration :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -486,8 +488,8 @@ def __init__( :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -611,7 +613,7 @@ class DiskAccessList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskAccess"], + value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs ): @@ -672,8 +674,8 @@ class DiskEncryptionSet(Resource): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2020_05_01.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype encryption_type: str or ~azure.mgmt.compute.v2020_05_01.models.EncryptionType :ivar active_key: The key vault key which is currently used by this disk encryption set. @@ -713,9 +715,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "EncryptionType"]] = None, - active_key: Optional["KeyVaultAndKeyReference"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.EncryptionType"]] = None, + active_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -726,8 +728,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2020_05_01.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype encryption_type: str or ~azure.mgmt.compute.v2020_05_01.models.EncryptionType :keyword active_key: The key vault key which is currently used by this disk encryption set. @@ -765,7 +767,7 @@ class DiskEncryptionSetList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskEncryptionSet"], + value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs ): @@ -786,8 +788,8 @@ class DiskEncryptionSetUpdate(msrest.serialization.Model): :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype encryption_type: str or ~azure.mgmt.compute.v2020_05_01.models.EncryptionType :ivar active_key: Key Vault Key Url and vault id of KeK, KeK is optional and when provided is @@ -805,15 +807,15 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - encryption_type: Optional[Union[str, "EncryptionType"]] = None, - active_key: Optional["KeyVaultAndKeyReference"] = None, + encryption_type: Optional[Union[str, "_models.EncryptionType"]] = None, + active_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype encryption_type: str or ~azure.mgmt.compute.v2020_05_01.models.EncryptionType :keyword active_key: Key Vault Key Url and vault id of KeK, KeK is optional and when provided @@ -850,7 +852,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -871,8 +873,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS". :vartype name: str or ~azure.mgmt.compute.v2020_05_01.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -890,11 +892,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype name: str or ~azure.mgmt.compute.v2020_05_01.models.DiskStorageAccountTypes """ @@ -911,7 +913,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :vartype sku: ~azure.mgmt.compute.v2020_05_01.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -942,8 +944,8 @@ class DiskUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -970,17 +972,17 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, max_shares: Optional[int] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, **kwargs ): @@ -990,7 +992,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :paramtype sku: ~azure.mgmt.compute.v2020_05_01.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1021,8 +1023,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -1051,7 +1053,7 @@ class Encryption(msrest.serialization.Model): :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Possible values include: + :ivar type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype type: str or ~azure.mgmt.compute.v2020_05_01.models.EncryptionType @@ -1066,14 +1068,14 @@ def __init__( self, *, disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "EncryptionType"]] = None, + type: Optional[Union[str, "_models.EncryptionType"]] = None, **kwargs ): """ :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Possible values include: + :keyword type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype type: str or ~azure.mgmt.compute.v2020_05_01.models.EncryptionType @@ -1089,7 +1091,7 @@ class EncryptionSetIdentity(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is - supported. Possible values include: "SystemAssigned". + supported. Known values are: "SystemAssigned". :vartype type: str or ~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSetIdentityType :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a @@ -1115,12 +1117,12 @@ class EncryptionSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "DiskEncryptionSetIdentityType"]] = None, + type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, **kwargs ): """ :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned - is supported. Possible values include: "SystemAssigned". + is supported. Known values are: "SystemAssigned". :paramtype type: str or ~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSetIdentityType """ super(EncryptionSetIdentity, self).__init__(**kwargs) @@ -1162,7 +1164,7 @@ def __init__( self, *, enabled: bool, - encryption_settings: Optional[List["EncryptionSettingsElement"]] = None, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, encryption_settings_version: Optional[str] = None, **kwargs ): @@ -1204,8 +1206,8 @@ class EncryptionSettingsElement(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -1226,7 +1228,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read", "Write". + :ivar access: Required. Known values are: "None", "Read", "Write". :vartype access: str or ~azure.mgmt.compute.v2020_05_01.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -1245,12 +1247,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read", "Write". + :keyword access: Required. Known values are: "None", "Read", "Write". :paramtype access: str or ~azure.mgmt.compute.v2020_05_01.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -1358,7 +1360,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -1397,7 +1399,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -1457,7 +1459,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype private_link_service_connection_state: ~azure.mgmt.compute.v2020_05_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.compute.v2020_05_01.models.PrivateEndpointConnectionProvisioningState """ @@ -1481,8 +1483,8 @@ class PrivateEndpointConnection(msrest.serialization.Model): 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 ): """ @@ -1571,7 +1573,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -1586,7 +1588,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.compute.v2020_05_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -1605,14 +1607,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, actions_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.compute.v2020_05_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -1677,10 +1679,10 @@ class Snapshot(Resource): :vartype sku: ~azure.mgmt.compute.v2020_05_01.models.SnapshotSku :ivar time_created: The time when the snapshot was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_05_01.models.HyperVGeneration :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1706,8 +1708,8 @@ class Snapshot(Resource): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -1754,15 +1756,15 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, incremental: Optional[bool] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, **kwargs ): @@ -1773,10 +1775,10 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2020_05_01.models.SnapshotSku - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_05_01.models.HyperVGeneration :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1796,8 +1798,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -1846,7 +1848,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -1867,8 +1869,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2020_05_01.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -1886,12 +1887,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2020_05_01.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -1906,7 +1906,7 @@ class SnapshotUpdate(msrest.serialization.Model): :vartype tags: dict[str, str] :ivar sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :vartype sku: ~azure.mgmt.compute.v2020_05_01.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1920,8 +1920,8 @@ class SnapshotUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -1943,12 +1943,12 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, **kwargs ): @@ -1957,7 +1957,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2020_05_01.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_05_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1971,8 +1971,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2020_05_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_05_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/__init__.py index 22cffb20eb1d..057394001370 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/__init__.py @@ -11,9 +11,14 @@ from ._disk_encryption_sets_operations import DiskEncryptionSetsOperations from ._disk_accesses_operations import DiskAccessesOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', 'DiskEncryptionSetsOperations', 'DiskAccessesOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_disk_accesses_operations.py index ea2996804509..99f2f79085d7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccess] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccessUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_get_private_link_resources_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,58 +284,57 @@ def build_get_private_link_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskAccessesOperations(object): - """DiskAccessesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_05_01.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -338,11 +346,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -372,9 +382,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -397,37 +407,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -444,17 +464,20 @@ def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -466,11 +489,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -500,9 +525,9 @@ def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -525,37 +550,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -574,7 +609,7 @@ def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -588,13 +623,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_05_01.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -603,11 +641,13 @@ def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -634,13 +674,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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', "2020-05-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -649,11 +692,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,20 +742,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -720,8 +770,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -739,7 +795,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -749,13 +805,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -764,9 +823,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -775,9 +836,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -814,7 +877,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -822,13 +885,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -836,9 +902,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -846,9 +914,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -887,7 +957,7 @@ def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -901,13 +971,16 @@ def get_private_link_resources( :rtype: ~azure.mgmt.compute.v2020_05_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', "2020-05-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -916,11 +989,13 @@ def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_disk_encryption_sets_operations.py index 0090a46302a9..c1d47253e278 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") path_format_arguments = { @@ -239,58 +247,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskEncryptionSetsOperations(object): - """DiskEncryptionSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_05_01.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -302,11 +309,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -336,9 +345,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -363,37 +372,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -410,17 +429,20 @@ def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -432,11 +454,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -466,9 +490,9 @@ def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -493,37 +517,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -542,7 +576,7 @@ def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -556,13 +590,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -571,11 +608,13 @@ def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -602,13 +641,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -617,11 +659,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -665,20 +709,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -688,8 +737,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -707,7 +762,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -719,13 +774,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -734,9 +792,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -745,9 +805,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -784,7 +846,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -794,13 +856,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -808,9 +873,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -818,9 +885,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_disks_operations.py index e033bbf89729..f76d317dcadc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_05_01.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_05_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2020-05-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_snapshots_operations.py index 638b4e4b88a8..d04a465056e9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_05_01/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_05_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_05_01.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_05_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_05_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_05_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2020-05-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-05-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_compute_management_client.py index b391ea021cdf..2b4ebda7d72c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_compute_management_client.py @@ -113,27 +113,69 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/_compute_management_client.py index 08e0e1778530..7f965a639aa9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/_compute_management_client.py @@ -115,27 +115,69 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/__init__.py index 504bd3ccebae..73170fb3554e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/__init__.py @@ -28,6 +28,9 @@ from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations from ._virtual_machine_scale_set_vm_run_commands_operations import VirtualMachineScaleSetVMRunCommandsOperations +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', 'AvailabilitySetsOperations', @@ -51,3 +54,5 @@ 'VirtualMachineRunCommandsOperations', 'VirtualMachineScaleSetVMRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_availability_sets_operations.py index b8559c13b347..d6906ff4e35d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_dedicated_host_groups_operations.py index 0f957207d0e1..8c48083c4056 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_dedicated_host_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostGroupsOperations: - """DedicatedHostGroupsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -137,14 +141,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -156,11 +163,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -199,13 +208,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,11 +226,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +256,7 @@ async def get( host_group_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -250,7 +264,7 @@ async def get( :param host_group_name: The name of the dedicated host group. :type host_group_name: str :param expand: The expand expression to apply on the operation. The response shows the list of - instance view of the dedicated hosts under the dedicated host group. Possible values are + instance view of the dedicated hosts under the dedicated host group. Known values are "instanceView" or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -258,13 +272,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -274,11 +291,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +323,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -317,13 +336,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -332,9 +354,11 @@ def prepare_request(next_link=None): 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: @@ -343,9 +367,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -382,7 +408,7 @@ async def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -393,13 +419,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -407,9 +436,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -417,9 +448,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_dedicated_hosts_operations.py index c02446112cb7..d642dfa74265 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostsOperations: - """DedicatedHostsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('DedicatedHost', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -267,17 +286,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -285,20 +307,27 @@ async def begin_update( 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('DedicatedHost', 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( @@ -318,13 +347,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -334,11 +366,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,21 +417,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -407,8 +446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -429,7 +474,7 @@ async def get( host_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -438,21 +483,24 @@ async def get( :type host_group_name: str :param host_name: The name of the dedicated host. :type host_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedHost, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -463,11 +511,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -494,7 +544,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostListResult"]: + ) -> AsyncIterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -509,13 +559,16 @@ def list_by_host_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -525,9 +578,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -537,9 +592,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_images_operations.py index 2949f526196e..896a6a9f7b61 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_log_analytics_operations.py index f4161577de4f..66433a435446 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_operations.py index 92c34629109c..c01710a06409 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_proximity_placement_groups_operations.py index 8d59e2cdd540..35b28c132df5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,7 +254,7 @@ async def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -255,13 +269,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -271,11 +288,13 @@ async def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -300,7 +319,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -310,13 +329,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -324,9 +346,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -334,9 +358,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -374,7 +400,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -386,13 +412,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,9 +430,11 @@ def prepare_request(next_link=None): 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: @@ -412,9 +443,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_ssh_public_keys_operations.py index b839c9431548..9f9a0b704685 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_ssh_public_keys_operations.py @@ -15,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 @@ -24,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SshPublicKeysOperations: - """SshPublicKeysOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -60,13 +59,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -74,9 +76,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -84,9 +88,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +130,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -137,13 +143,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -152,9 +161,11 @@ def prepare_request(next_link=None): 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: @@ -163,9 +174,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -203,9 +216,9 @@ async def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -219,14 +232,17 @@ async def create( :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -238,11 +254,13 @@ async def create( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -272,9 +290,9 @@ async def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -288,14 +306,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -307,11 +328,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -350,13 +373,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -365,11 +391,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,7 +420,7 @@ async def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -404,13 +432,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -419,11 +450,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,7 +483,7 @@ async def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -464,13 +497,16 @@ async def generate_key_pair( :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -479,11 +515,13 @@ async def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_usage_operations.py index 249bbfecb657..72dc83f40ec4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_extension_images_operations.py index 3d657d69fdb5..8b16b39b94ca 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_extensions_operations.py index dab3ebc1321c..2839ccaad438 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_images_operations.py index 87fbb6a60bc1..acfb714288e5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_run_commands_operations.py index bbc55b268824..913a34ee0122 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -64,13 +63,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,7 +137,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -143,13 +149,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -158,11 +167,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,18 +199,21 @@ async def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -212,11 +226,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,11 +263,11 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -263,7 +279,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -280,16 +296,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -297,20 +316,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -328,18 +354,21 @@ async def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -352,11 +381,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,11 +414,11 @@ async def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -398,7 +429,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -415,16 +446,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -432,20 +466,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -465,13 +506,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -481,11 +525,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,21 +576,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -554,8 +605,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -576,7 +633,7 @@ async def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -592,13 +649,16 @@ async def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -609,11 +669,13 @@ async def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -641,7 +703,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -657,13 +719,16 @@ def list_by_virtual_machine( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -674,9 +739,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -687,9 +754,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index 5960886d6061..84d9e1889396 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -189,17 +203,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -212,11 +229,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -276,17 +295,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -294,20 +316,27 @@ async def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -327,13 +356,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -343,11 +375,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,21 +426,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -416,8 +455,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -438,7 +483,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -516,13 +566,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -532,9 +585,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -544,9 +599,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 1565237a7ee0..2bf7a7d01c58 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,13 +292,16 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu vm_scale_set_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -276,11 +310,13 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,20 +360,25 @@ async def begin_start_extension_upgrade( # pylint: disable=inconsistent-return- :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_extension_upgrade_initial( + raw_result = await self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -347,8 +388,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -367,7 +414,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -379,13 +426,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -394,11 +444,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py index 1ddc58f26c35..25dfcb9f5a94 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMExtensionsOperations: - """VirtualMachineScaleSetVMExtensionsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -51,17 +50,20 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -111,9 +115,9 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -161,20 +168,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -193,17 +207,20 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -217,11 +234,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -249,9 +268,9 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -280,17 +299,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -299,20 +321,27 @@ async def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -333,13 +362,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -350,11 +382,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -402,22 +436,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -427,8 +466,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -450,7 +495,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -468,13 +513,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -486,11 +534,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -519,7 +569,7 @@ async def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -535,13 +585,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -552,11 +605,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index 632ebb32c7ac..6c067a131943 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMRunCommandsOperations: - """VirtualMachineScaleSetVMRunCommandsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,18 +52,21 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -78,11 +80,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -114,11 +118,11 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -131,7 +135,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -148,16 +152,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -166,20 +173,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -198,18 +212,21 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -223,11 +240,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,11 +274,11 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -272,7 +291,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -289,16 +308,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -307,20 +329,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -341,13 +370,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -358,11 +390,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -410,22 +444,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -435,8 +474,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -458,7 +503,7 @@ async def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -476,13 +521,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_request( @@ -494,11 +542,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +577,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -545,13 +595,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -563,9 +616,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -577,9 +632,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index ce63dc663d6c..08f09f5a9ed4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -78,11 +80,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -132,17 +136,20 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -150,6 +157,8 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,13 +195,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -196,11 +214,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,21 +266,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -270,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -291,13 +322,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -307,11 +341,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,21 +394,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -382,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -401,17 +448,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -424,11 +474,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,9 +511,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -487,17 +539,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -505,20 +560,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -538,13 +600,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -554,11 +619,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -603,21 +670,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -627,8 +699,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -649,7 +727,7 @@ async def get( instance_id: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -658,21 +736,24 @@ async def get( :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. :type instance_id: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachineScaleSetVM, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -683,11 +764,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -715,7 +798,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -729,13 +812,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -745,11 +831,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -779,7 +867,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -803,13 +891,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -822,9 +913,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -837,9 +930,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -880,13 +975,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -897,11 +995,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -953,22 +1053,27 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -978,8 +1083,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -999,13 +1110,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1015,11 +1129,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1064,21 +1180,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1088,8 +1209,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1109,13 +1236,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1125,11 +1255,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1174,21 +1306,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1198,8 +1335,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1219,13 +1362,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1235,11 +1381,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1285,21 +1433,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1309,8 +1462,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1331,7 +1490,7 @@ async def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -1350,13 +1509,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2020_06_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1367,11 +1529,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1399,13 +1563,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1415,11 +1582,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1464,21 +1633,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1488,8 +1662,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1523,13 +1703,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -1539,11 +1722,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1565,18 +1750,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1589,11 +1777,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1622,11 +1812,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1637,7 +1827,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2020_06_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1654,16 +1844,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1671,20 +1864,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_sets_operations.py index 23e1f24d9a55..0c342ca67ad0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -231,9 +250,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -409,7 +454,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -421,13 +466,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -436,11 +484,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -465,17 +515,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -490,11 +543,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -516,7 +571,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -543,23 +598,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -569,8 +629,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -587,17 +653,20 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -609,11 +678,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,7 +706,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -659,23 +730,28 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +761,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +787,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -717,13 +799,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -732,11 +817,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -762,7 +849,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -774,13 +861,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -789,9 +879,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -800,9 +892,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -839,7 +933,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -851,13 +945,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -865,9 +962,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -875,9 +974,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +1017,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -931,13 +1032,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -947,9 +1051,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -959,9 +1065,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1000,7 +1108,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1014,13 +1122,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1030,9 +1141,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1042,9 +1155,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1082,17 +1197,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1108,11 +1226,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1135,7 +1255,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1166,17 +1286,20 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -1184,6 +1307,8 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1193,8 +1318,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1211,17 +1342,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1236,11 +1370,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1262,7 +1398,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1287,23 +1423,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1313,8 +1454,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1331,17 +1478,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1356,11 +1506,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1382,7 +1534,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1407,23 +1559,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1433,8 +1590,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1451,17 +1614,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1476,11 +1642,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1502,7 +1670,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1528,23 +1696,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1554,8 +1727,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1572,17 +1751,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1597,11 +1779,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1623,7 +1807,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1651,23 +1835,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1677,8 +1866,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1695,17 +1890,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1717,11 +1915,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1743,7 +1943,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1767,23 +1967,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1793,8 +1998,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1811,17 +2022,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -1836,11 +2050,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1862,7 +2078,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -1888,23 +2104,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1914,8 +2135,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1932,17 +2159,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1957,11 +2187,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1983,7 +2215,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2009,23 +2241,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2035,8 +2272,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2056,7 +2299,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2072,13 +2315,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2020_06_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2088,11 +2334,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2118,7 +2366,7 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -2135,14 +2383,17 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret :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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -2154,11 +2405,13 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2179,17 +2432,20 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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(parameters, 'OrchestrationServiceStateInput') @@ -2201,11 +2457,13 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2227,7 +2485,7 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> AsyncLROPoller[None]: """Changes ServiceState property for a given service. @@ -2250,23 +2508,28 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + 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._set_orchestration_service_state_initial( + raw_result = await self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -2276,8 +2539,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_sizes_operations.py index a366c3a995d7..0dc32683a257 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machines_operations.py index 14133132e974..e423b41730f7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_06_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -338,37 +364,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -385,17 +421,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -407,11 +446,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -441,9 +482,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -466,37 +507,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -516,13 +567,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -532,11 +586,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -582,21 +638,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -606,8 +667,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -627,28 +694,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -658,11 +728,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -689,7 +761,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -701,13 +773,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -716,11 +791,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -747,13 +824,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -762,11 +842,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -809,20 +891,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -832,8 +919,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -852,13 +945,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -867,11 +963,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -914,20 +1012,25 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -937,8 +1040,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -974,13 +1083,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -989,11 +1101,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1015,7 +1129,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1028,13 +1142,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1043,9 +1160,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1054,9 +1173,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1094,7 +1215,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1108,13 +1229,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1123,9 +1247,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1134,9 +1260,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1175,7 +1303,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1190,13 +1318,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1206,9 +1337,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1218,9 +1351,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1260,13 +1395,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1276,11 +1414,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1328,21 +1468,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1352,8 +1497,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1372,13 +1523,16 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -1387,11 +1541,13 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1433,20 +1589,25 @@ async def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reapply_initial( + raw_result = await self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1456,8 +1617,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1476,13 +1643,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1491,11 +1661,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1537,20 +1709,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1560,8 +1737,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1580,13 +1763,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1595,11 +1781,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1641,20 +1829,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1664,8 +1857,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1684,13 +1883,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1699,11 +1901,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1745,20 +1949,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1768,8 +1977,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1786,17 +2001,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -1811,11 +2029,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1837,7 +2057,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -1861,23 +2081,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -1887,8 +2112,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1908,7 +2139,7 @@ async def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -1924,13 +2155,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2020_06_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1940,11 +2174,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1971,13 +2207,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1986,11 +2225,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2032,20 +2273,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2055,8 +2301,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2087,13 +2339,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2102,11 +2357,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2128,14 +2385,17 @@ async def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -2144,11 +2404,13 @@ async def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2177,7 +2439,7 @@ async def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -2198,34 +2460,44 @@ async def begin_assess_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = await self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -2242,18 +2514,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2265,11 +2540,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2297,11 +2574,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2310,7 +2587,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2020_06_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2327,36 +2604,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/__init__.py index 34d4aa95548e..49d9ef19d3a1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/__init__.py @@ -245,7 +245,9 @@ VirtualMachineSizeTypes, VmDiskTypes, ) - +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__ = [ 'AdditionalCapabilities', 'AdditionalUnattendContent', @@ -483,3 +485,5 @@ 'VirtualMachineSizeTypes', 'VmDiskTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_compute_management_client_enums.py index 171d24463117..43515e46790c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. """ @@ -19,7 +18,7 @@ class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CLASSIC = "Classic" ALIGNED = "Aligned" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -30,7 +29,7 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the software license type that will be applied to the VMs deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` @@ -41,13 +40,13 @@ class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" -class DiffDiskOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk option for operating system disk. """ LOCAL = "Local" -class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskPlacement(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk placement for operating system disk. This property can be used by user in the request to choose the location i.e, cache disk or resource disk space for Ephemeral OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer @@ -60,7 +59,7 @@ class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CACHE_DISK = "CacheDisk" RESOURCE_DISK = "ResourceDisk" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -73,7 +72,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExecutionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Script execution status. """ @@ -85,21 +84,21 @@ class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TIMED_OUT = "TimedOut" CANCELED = "Canceled" -class HyperVGenerationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type associated with a resource """ V1 = "V1" V2 = "V2" -class HyperVGenerationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type """ V1 = "V1" V2 = "V2" -class InGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of in-guest patching to IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of patches to a virtual machine. You do this by applying patches manually inside the VM. In this @@ -115,7 +114,7 @@ class InGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTOMATIC_BY_OS = "AutomaticByOS" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -124,7 +123,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -133,7 +132,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -142,7 +141,7 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ @@ -151,20 +150,20 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: Specialized image. Contains already provisioned OS Disk. SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class OrchestrationServiceNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the service. """ AUTOMATIC_REPAIRS = "AutomaticRepairs" -class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current state of the service. """ @@ -172,14 +171,14 @@ class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enu RUNNING = "Running" SUSPENDED = "Suspended" -class OrchestrationServiceStateAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceStateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The action to be performed. """ RESUME = "Resume" SUSPEND = "Suspend" -class PatchAssessmentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchAssessmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the outcome of an install operation for a given patch. """ @@ -190,7 +189,7 @@ class PatchAssessmentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PENDING = "Pending" AVAILABLE = "Available" -class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Failed", "Succeeded", or "CompletedWithWarnings." @@ -201,7 +200,7 @@ class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -209,7 +208,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -218,7 +217,7 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class RebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RebootStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reboot status of the machine after the patch operation. It will be in "NotNeeded" status if reboot is not needed after the patch operation. "Required" will be the status once the patch is applied and machine is required to reboot. "Started" will be the reboot status when the machine @@ -232,7 +231,7 @@ class RebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" COMPLETED = "Completed" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -243,14 +242,14 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -259,7 +258,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -267,7 +266,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class SoftwareUpdateRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SoftwareUpdateRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the reboot requirements of the patch. """ @@ -275,7 +274,7 @@ class SoftwareUpdateRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, ALWAYS_REQUIRES_REBOOT = "AlwaysRequiresReboot" CAN_REQUEST_REBOOT = "CanRequestReboot" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -283,7 +282,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. StandardSSD_LRS uses Standard SSD. Premium_LRS uses Premium SSD. UltraSSD_LRS uses Ultra disk. @@ -298,7 +297,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_SSD_LRS = "StandardSSD_LRS" ULTRA_SSD_LRS = "UltraSSD_LRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -310,7 +309,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -318,7 +317,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -327,14 +326,14 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for the Azure Spot VM/VMSS """ DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for a standalone virtual machine or the virtual machines in the scale set. :code:`
`:code:`
` 'Low' enum will be deprecated in the future, please use 'Spot' as the enum to deploy Azure Spot VM/VMSS. @@ -344,20 +343,20 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E LOW = "Low" SPOT = "Spot" -class VirtualMachineScaleSetScaleInRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "Default" OLDEST_VM = "OldestVM" NEWEST_VM = "NewestVM" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The @@ -543,7 +542,7 @@ class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) STANDARD_NV12 = "Standard_NV12" STANDARD_NV24 = "Standard_NV24" -class VmDiskTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VmDiskTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """VM disk types which are disallowed. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_models_py3.py index fb8ea0062715..ee72b832db8b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AdditionalCapabilities(msrest.serialization.Model): @@ -56,7 +58,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2020_06_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -77,7 +79,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -90,7 +92,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2020_06_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -158,8 +160,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -461,11 +463,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -523,7 +525,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -605,11 +607,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -645,7 +647,7 @@ class AvailablePatchSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Failed", "Succeeded", or - "CompletedWithWarnings.". Possible values include: "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings.". Known values are: "InProgress", "Failed", "Succeeded", "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2020_06_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is @@ -934,8 +936,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -946,7 +947,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -993,14 +994,14 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, to_be_detached: Optional[bool] = None, **kwargs ): @@ -1020,8 +1021,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1032,7 +1032,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1121,7 +1121,7 @@ class DedicatedHost(Resource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1166,11 +1166,11 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1191,7 +1191,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostLicenseTypes """ @@ -1257,7 +1257,7 @@ class DedicatedHostAvailableCapacity(msrest.serialization.Model): def __init__( self, *, - allocatable_v_ms: Optional[List["DedicatedHostAllocatableVM"]] = None, + allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs ): """ @@ -1379,7 +1379,7 @@ class DedicatedHostGroupInstanceView(msrest.serialization.Model): def __init__( self, *, - hosts: Optional[List["DedicatedHostInstanceViewWithName"]] = None, + hosts: Optional[List["_models.DedicatedHostInstanceViewWithName"]] = None, **kwargs ): """ @@ -1415,7 +1415,7 @@ class DedicatedHostGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHostGroup"], + value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs ): @@ -1533,8 +1533,8 @@ class DedicatedHostInstanceView(msrest.serialization.Model): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1582,8 +1582,8 @@ class DedicatedHostInstanceViewWithName(DedicatedHostInstanceView): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1621,7 +1621,7 @@ class DedicatedHostListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHost"], + value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs ): @@ -1658,7 +1658,7 @@ class DedicatedHostUpdate(UpdateResource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1695,7 +1695,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1711,7 +1711,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostLicenseTypes """ @@ -1743,7 +1743,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -1760,8 +1760,8 @@ def __init__( class DiffDiskSettings(msrest.serialization.Model): """Describes the parameters of ephemeral disk settings that can be specified for operating system disk. :code:`
`:code:`
` NOTE: The ephemeral disk settings can only be specified for managed disk. - :ivar option: Specifies the ephemeral disk settings for operating system disk. Possible values - include: "Local". + :ivar option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :vartype option: str or ~azure.mgmt.compute.v2020_06_01.models.DiffDiskOptions :ivar placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -1770,7 +1770,7 @@ class DiffDiskSettings(msrest.serialization.Model): Refer to VM size documentation for Windows VM at https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes to check which VM sizes - exposes a cache disk. Possible values include: "CacheDisk", "ResourceDisk". + exposes a cache disk. Known values are: "CacheDisk", "ResourceDisk". :vartype placement: str or ~azure.mgmt.compute.v2020_06_01.models.DiffDiskPlacement """ @@ -1782,13 +1782,13 @@ class DiffDiskSettings(msrest.serialization.Model): def __init__( self, *, - option: Optional[Union[str, "DiffDiskOptions"]] = None, - placement: Optional[Union[str, "DiffDiskPlacement"]] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, + placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, **kwargs ): """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. Possible - values include: "Local". + :keyword option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :paramtype option: str or ~azure.mgmt.compute.v2020_06_01.models.DiffDiskOptions :keyword placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -1797,7 +1797,7 @@ def __init__( Refer to VM size documentation for Windows VM at https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes to check which VM sizes - exposes a cache disk. Possible values include: "CacheDisk", "ResourceDisk". + exposes a cache disk. Known values are: "CacheDisk", "ResourceDisk". :paramtype placement: str or ~azure.mgmt.compute.v2020_06_01.models.DiffDiskPlacement """ super(DiffDiskSettings, self).__init__(**kwargs) @@ -1808,8 +1808,7 @@ def __init__( class DisallowedConfiguration(msrest.serialization.Model): """Specifies the disallowed configuration for a virtual machine image. - :ivar vm_disk_type: VM disk types which are disallowed. Possible values include: "None", - "Unmanaged". + :ivar vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :vartype vm_disk_type: str or ~azure.mgmt.compute.v2020_06_01.models.VmDiskTypes """ @@ -1820,11 +1819,11 @@ class DisallowedConfiguration(msrest.serialization.Model): def __init__( self, *, - vm_disk_type: Optional[Union[str, "VmDiskTypes"]] = None, + vm_disk_type: Optional[Union[str, "_models.VmDiskTypes"]] = None, **kwargs ): """ - :keyword vm_disk_type: VM disk types which are disallowed. Possible values include: "None", + :keyword vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :paramtype vm_disk_type: str or ~azure.mgmt.compute.v2020_06_01.models.VmDiskTypes """ @@ -1902,8 +1901,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -1945,8 +1944,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1983,7 +1982,7 @@ class HardwareProfile(msrest.serialization.Model): **VirtualMachineSizeTypes** string constants will be removed from the subsequent REST API specification. Use `List all available virtual machine sizes in a region `_ to get the latest - sizes. Possible values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", + sizes. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", @@ -2028,7 +2027,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -2047,7 +2046,7 @@ def __init__( **VirtualMachineSizeTypes** string constants will be removed from the subsequent REST API specification. Use `List all available virtual machine sizes in a region `_ to get the latest - sizes. Possible values include: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", + sizes. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", "Standard_A4_v2", "Standard_A8_v2", "Standard_A2m_v2", @@ -2112,7 +2111,7 @@ class Image(Resource): :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Possible values include: "V1", "V2". + image. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationTypes """ @@ -2142,9 +2141,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -2157,7 +2156,7 @@ def __init__( :keyword storage_profile: Specifies the storage settings for the virtual machine disks. :paramtype storage_profile: ~azure.mgmt.compute.v2020_06_01.models.ImageStorageProfile :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Possible values include: "V1", "V2". + the image. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationTypes """ @@ -2180,16 +2179,15 @@ class ImageDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -2211,13 +2209,13 @@ class ImageDisk(msrest.serialization.Model): def __init__( self, *, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -2230,16 +2228,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -2271,16 +2268,15 @@ class ImageDataDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -2312,13 +2308,13 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -2331,16 +2327,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -2380,7 +2375,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -2410,16 +2405,15 @@ class ImageOSDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -2428,10 +2422,10 @@ class ImageOSDisk(ImageDisk): ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSetParameters :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemStateTypes """ @@ -2455,15 +2449,15 @@ class ImageOSDisk(ImageDisk): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -2476,16 +2470,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -2494,11 +2487,10 @@ def __init__( ~azure.mgmt.compute.v2020_06_01.models.DiskEncryptionSetParameters :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemStateTypes """ super(ImageOSDisk, self).__init__(snapshot=snapshot, managed_disk=managed_disk, blob_uri=blob_uri, caching=caching, disk_size_gb=disk_size_gb, storage_account_type=storage_account_type, disk_encryption_set=disk_encryption_set, **kwargs) @@ -2607,8 +2599,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -2647,7 +2639,7 @@ class ImageUpdate(UpdateResource): :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str :ivar hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from the - image. Possible values include: "V1", "V2". + image. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationTypes """ @@ -2668,9 +2660,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -2681,7 +2673,7 @@ def __init__( :keyword storage_profile: Specifies the storage settings for the virtual machine disks. :paramtype storage_profile: ~azure.mgmt.compute.v2020_06_01.models.ImageStorageProfile :keyword hyper_v_generation: Gets the HyperVGenerationType of the VirtualMachine created from - the image. Possible values include: "V1", "V2". + the image. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationTypes """ @@ -2729,7 +2721,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2020_06_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -2751,7 +2743,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -2760,7 +2752,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2020_06_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -2802,7 +2794,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -2841,7 +2833,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -2862,7 +2854,7 @@ class LastPatchInstallationSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Failed", "Succeeded", or - "CompletedWithWarnings.". Possible values include: "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings.". Known values are: "InProgress", "Failed", "Succeeded", "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2020_06_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It @@ -2876,8 +2868,7 @@ class LastPatchInstallationSummary(msrest.serialization.Model): status once the patch is applied and machine is required to reboot. "Started" will be the reboot status when the machine has started to reboot. "Failed" will be the status if the machine is failed to reboot. "Completed" will be the status once the machine is rebooted - successfully. Possible values include: "NotNeeded", "Required", "Started", "Failed", - "Completed". + successfully. Known values are: "NotNeeded", "Required", "Started", "Failed", "Completed". :vartype reboot_status: str or ~azure.mgmt.compute.v2020_06_01.models.RebootStatus :ivar not_selected_patch_count: The number of all available patches but not going to be installed because it didn't match a classification or inclusion list entry. @@ -2982,7 +2973,7 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, provision_vm_agent: Optional[bool] = None, **kwargs ): @@ -3028,7 +3019,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -3196,8 +3187,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2020_06_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -3222,7 +3213,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -3238,8 +3229,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2020_06_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -3262,8 +3253,8 @@ class ManagedDiskParameters(SubResource): :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can - only be used with data disks, it cannot be used with OS Disk. Possible values include: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", + "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -3282,8 +3273,8 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3291,7 +3282,7 @@ def __init__( :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS - can only be used with data disks, it cannot be used with OS Disk. Possible values include: + can only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes @@ -3354,7 +3345,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -3372,11 +3363,9 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :ivar service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceNames - :ivar action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :ivar action: Required. The action to be performed. Known values are: "Resume", "Suspend". :vartype action: str or ~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceStateAction """ @@ -3393,17 +3382,15 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): def __init__( self, *, - service_name: Union[str, "OrchestrationServiceNames"], - action: Union[str, "OrchestrationServiceStateAction"], + service_name: Union[str, "_models.OrchestrationServiceNames"], + action: Union[str, "_models.OrchestrationServiceStateAction"], **kwargs ): """ - :keyword service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :keyword service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :paramtype service_name: str or ~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceNames - :keyword action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :keyword action: Required. The action to be performed. Known values are: "Resume", "Suspend". :paramtype action: str or ~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceStateAction """ @@ -3417,9 +3404,9 @@ class OrchestrationServiceSummary(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar service_name: The name of the service. Possible values include: "AutomaticRepairs". + :ivar service_name: The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceNames - :ivar service_state: The current state of the service. Possible values include: "NotRunning", + :ivar service_state: The current state of the service. Known values are: "NotRunning", "Running", "Suspended". :vartype service_state: str or ~azure.mgmt.compute.v2020_06_01.models.OrchestrationServiceState """ @@ -3452,8 +3439,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -3469,8 +3456,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -3484,7 +3470,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -3515,24 +3501,24 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -3548,8 +3534,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -3563,7 +3548,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -3591,8 +3576,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes """ @@ -3607,12 +3592,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -3713,9 +3698,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, require_guest_provision_signal: Optional[bool] = None, **kwargs @@ -3817,8 +3802,8 @@ class PatchSettings(msrest.serialization.Model): **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2020_06_01.models.InGuestPatchMode """ @@ -3829,7 +3814,7 @@ class PatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "InGuestPatchMode"]] = None, + patch_mode: Optional[Union[str, "_models.InGuestPatchMode"]] = None, **kwargs ): """ @@ -3841,8 +3826,8 @@ def __init__( **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2020_06_01.models.InGuestPatchMode """ super(PatchSettings, self).__init__(**kwargs) @@ -3917,7 +3902,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -3964,8 +3949,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -3976,7 +3961,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroupType :keyword colocation_status: Describes colocation status of the Proximity Placement Group. @@ -4013,7 +3998,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -4157,7 +4142,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_user_agent: Group query result by User Agent. :vartype group_by_user_agent: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2020_06_01.models.IntervalInMins """ @@ -4186,7 +4171,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -4213,7 +4198,7 @@ def __init__( :keyword group_by_user_agent: Group query result by User Agent. :paramtype group_by_user_agent: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2020_06_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, group_by_client_application_id=group_by_client_application_id, group_by_user_agent=group_by_user_agent, **kwargs) @@ -4414,13 +4399,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -4533,8 +4518,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -4563,7 +4547,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -4573,8 +4557,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -4598,8 +4581,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -4635,11 +4617,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -4647,8 +4629,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -4694,7 +4675,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -4775,7 +4756,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -4858,7 +4839,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -4897,7 +4878,7 @@ class ScaleInPolicy(msrest.serialization.Model): def __init__( self, *, - rules: Optional[List[Union[str, "VirtualMachineScaleSetScaleInRules"]]] = None, + rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, **kwargs ): """ @@ -4938,7 +4919,7 @@ class ScheduledEventsProfile(msrest.serialization.Model): def __init__( self, *, - terminate_notification_profile: Optional["TerminateNotificationProfile"] = None, + terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs ): """ @@ -5041,7 +5022,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -5236,7 +5217,7 @@ class SshPublicKeysGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["SshPublicKeyResource"], + value: List["_models.SshPublicKeyResource"], next_link: Optional[str] = None, **kwargs ): @@ -5318,9 +5299,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -5392,7 +5373,7 @@ def __init__( self, *, id: Optional[str] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -5569,7 +5550,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2020_06_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2020_06_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -5616,7 +5597,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2020_06_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -5656,8 +5637,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2020_06_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -5677,9 +5658,9 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["AutomaticOSUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, + automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, **kwargs ): """ @@ -5687,8 +5668,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2020_06_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -5742,7 +5723,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -5896,8 +5877,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -6012,14 +5993,13 @@ class VirtualMachine(Resource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -6105,24 +6085,24 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, **kwargs @@ -6188,15 +6168,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -6275,8 +6254,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -6301,7 +6280,7 @@ class VirtualMachineAssessPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Failed", "Succeeded", or - "CompletedWithWarnings.". Possible values include: "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings.". Known values are: "InProgress", "Failed", "Succeeded", "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2020_06_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is @@ -6548,7 +6527,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -6617,7 +6596,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -6754,8 +6733,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -6792,7 +6771,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -6933,8 +6912,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2020_06_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -6958,15 +6937,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2020_06_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -7062,8 +7041,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2020_06_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: "V1", - "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationTypes :ivar disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -7096,12 +7074,12 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, - disallowed: Optional["DisallowedConfiguration"] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, + automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, + disallowed: Optional["_models.DisallowedConfiguration"] = None, **kwargs ): """ @@ -7126,8 +7104,7 @@ def __init__( image. :paramtype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2020_06_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: - "V1", "V2". + :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationTypes :keyword disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -7158,8 +7135,8 @@ class VirtualMachineInstanceView(msrest.serialization.Model): :vartype os_name: str :ivar os_version: The version of Operating System running on the virtual machine. :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationType :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. :vartype rdp_thumb_print: str @@ -7223,15 +7200,15 @@ def __init__( computer_name: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationType"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, - patch_status: Optional["VirtualMachinePatchStatus"] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, + patch_status: Optional["_models.VirtualMachinePatchStatus"] = None, **kwargs ): """ @@ -7246,7 +7223,7 @@ def __init__( :keyword os_version: The version of Operating System running on the virtual machine. :paramtype os_version: str :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_01.models.HyperVGenerationType :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. @@ -7314,7 +7291,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -7350,8 +7327,8 @@ class VirtualMachinePatchStatus(msrest.serialization.Model): def __init__( self, *, - available_patch_summary: Optional["AvailablePatchSummary"] = None, - last_patch_installation_summary: Optional["LastPatchInstallationSummary"] = None, + available_patch_summary: Optional["_models.AvailablePatchSummary"] = None, + last_patch_installation_summary: Optional["_models.LastPatchInstallationSummary"] = None, **kwargs ): """ @@ -7476,9 +7453,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -7533,7 +7510,7 @@ def __init__( class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): """The instance view of a virtual machine run command. - :ivar execution_state: Script execution status. Possible values include: "Unknown", "Pending", + :ivar execution_state: Script execution status. Known values are: "Unknown", "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :vartype execution_state: str or ~azure.mgmt.compute.v2020_06_01.models.ExecutionState :ivar execution_message: Communicate script configuration errors or execution messages. @@ -7566,19 +7543,19 @@ class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): def __init__( self, *, - execution_state: Optional[Union[str, "ExecutionState"]] = None, + execution_state: Optional[Union[str, "_models.ExecutionState"]] = None, execution_message: Optional[str] = None, exit_code: Optional[int] = None, output: Optional[str] = None, error: Optional[str] = None, start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ - :keyword execution_state: Script execution status. Possible values include: "Unknown", - "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". + :keyword execution_state: Script execution status. Known values are: "Unknown", "Pending", + "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :paramtype execution_state: str or ~azure.mgmt.compute.v2020_06_01.models.ExecutionState :keyword execution_message: Communicate script configuration errors or execution messages. :paramtype execution_message: str @@ -7668,7 +7645,7 @@ class VirtualMachineRunCommandsListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineRunCommand"], + value: List["_models.VirtualMachineRunCommand"], next_link: Optional[str] = None, **kwargs ): @@ -7744,9 +7721,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -7910,22 +7887,22 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, **kwargs ): """ @@ -8022,14 +7999,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -8069,12 +8045,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -8089,14 +8065,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -8271,7 +8246,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -8308,7 +8283,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, extensions_time_budget: Optional[str] = None, **kwargs ): @@ -8460,7 +8435,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2020_06_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine @@ -8485,15 +8460,15 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2020_06_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual @@ -8576,7 +8551,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -8637,7 +8612,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2020_06_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -8681,14 +8656,14 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -8706,7 +8681,7 @@ def __init__( ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2020_06_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -8798,7 +8773,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -8839,7 +8814,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -8879,7 +8854,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -8919,7 +8894,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -8939,8 +8914,8 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): """Describes the parameters of a ScaleSet managed disk. :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -8957,14 +8932,14 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_06_01.models.StorageAccountTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -9030,9 +9005,9 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -9116,8 +9091,8 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -9144,8 +9119,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -9154,8 +9128,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -9166,8 +9140,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk @@ -9199,16 +9173,16 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -9217,8 +9191,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -9227,8 +9200,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2020_06_01.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -9240,7 +9213,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2020_06_01.models.VirtualHardDisk @@ -9339,9 +9312,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -9428,7 +9401,7 @@ class VirtualMachineScaleSetPublicIPAddressConfiguration(msrest.serialization.Mo :vartype public_ip_prefix: ~azure.mgmt.compute.v2020_06_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2020_06_01.models.IPVersion """ @@ -9450,10 +9423,10 @@ def __init__( *, name: str, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersion"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, **kwargs ): """ @@ -9470,7 +9443,7 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2020_06_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2020_06_01.models.IPVersion """ super(VirtualMachineScaleSetPublicIPAddressConfiguration, self).__init__(**kwargs) @@ -9628,8 +9601,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -9691,9 +9663,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -9784,18 +9756,18 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - proximity_placement_group: Optional["SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -9873,7 +9845,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2020_06_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -9907,14 +9879,14 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -9932,7 +9904,7 @@ def __init__( ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2020_06_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -10007,9 +9979,9 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -10067,8 +10039,8 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, **kwargs ): """ @@ -10088,7 +10060,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -10120,16 +10092,16 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_06_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -10181,9 +10153,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -10226,7 +10198,7 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, **kwargs ): """ @@ -10265,9 +10237,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -10329,15 +10301,15 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, **kwargs ): """ @@ -10521,18 +10493,18 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - network_profile_configuration: Optional["VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, - protection_policy: Optional["VirtualMachineScaleSetVMProtectionPolicy"] = None, + protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, **kwargs ): """ @@ -10693,7 +10665,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -10752,7 +10724,7 @@ class VirtualMachineScaleSetVMExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineScaleSetVMExtension"]] = None, + value: Optional[List["_models.VirtualMachineScaleSetVMExtension"]] = None, **kwargs ): """ @@ -11028,12 +11000,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -11104,7 +11076,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -11135,7 +11107,7 @@ class VirtualMachineScaleSetVMNetworkProfileConfiguration(msrest.serialization.M def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -11182,15 +11154,14 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -11218,17 +11189,17 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, **kwargs ): """ @@ -11264,15 +11235,14 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -11412,7 +11382,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -11438,7 +11408,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype kbid: str :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] - :ivar reboot_behavior: Describes the reboot requirements of the patch. Possible values include: + :ivar reboot_behavior: Describes the reboot requirements of the patch. Known values are: "NeverReboots", "AlwaysRequiresReboot", "CanRequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.compute.v2020_06_01.models.SoftwareUpdateRebootBehavior @@ -11449,9 +11419,8 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype published_date: ~datetime.datetime :ivar last_modified_date_time: The UTC timestamp of the last update to this patch record. :vartype last_modified_date_time: ~datetime.datetime - :ivar assessment_state: Describes the outcome of an install operation for a given patch. - Possible values include: "Installed", "Failed", "Excluded", "NotSelected", "Pending", - "Available". + :ivar assessment_state: Describes the outcome of an install operation for a given patch. Known + values are: "Installed", "Failed", "Excluded", "NotSelected", "Pending", "Available". :vartype assessment_state: str or ~azure.mgmt.compute.v2020_06_01.models.PatchAssessmentState """ @@ -11594,14 +11563,13 @@ class VirtualMachineUpdate(UpdateResource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -11676,24 +11644,24 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, **kwargs @@ -11757,15 +11725,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2020_06_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -11896,9 +11863,9 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - patch_settings: Optional["PatchSettings"] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + patch_settings: Optional["_models.PatchSettings"] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -11950,7 +11917,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -11965,7 +11932,7 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :vartype protocol: str or ~azure.mgmt.compute.v2020_06_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as @@ -11986,13 +11953,13 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2020_06_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/__init__.py index 504bd3ccebae..73170fb3554e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/__init__.py @@ -28,6 +28,9 @@ from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations from ._virtual_machine_scale_set_vm_run_commands_operations import VirtualMachineScaleSetVMRunCommandsOperations +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', 'AvailabilitySetsOperations', @@ -51,3 +54,5 @@ 'VirtualMachineRunCommandsOperations', 'VirtualMachineScaleSetVMRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_availability_sets_operations.py index cf0ce4ef30b9..0bc7814a0c73 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +190,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -199,20 +205,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -235,18 +242,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -257,9 +262,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -271,51 +279,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -329,14 +333,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -348,11 +355,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -378,9 +387,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -394,14 +403,17 @@ def update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -413,11 +425,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,13 +470,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -471,11 +488,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -498,7 +517,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -510,13 +529,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -525,11 +547,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -555,7 +579,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -568,13 +592,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -583,9 +610,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +623,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -634,7 +665,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -646,13 +677,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +695,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -672,9 +708,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -713,7 +751,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -728,13 +766,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -756,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_dedicated_host_groups_operations.py index d20debd1a1b8..255fd7ad5f49 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_dedicated_host_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +172,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -190,9 +193,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -203,18 +209,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -223,9 +227,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") path_format_arguments = { @@ -235,51 +242,47 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostGroupsOperations(object): - """DedicatedHostGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -295,14 +298,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -314,11 +320,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -348,9 +356,9 @@ def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -364,14 +372,17 @@ def update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -383,11 +394,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -426,13 +439,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -441,11 +457,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -469,7 +487,7 @@ def get( host_group_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -477,7 +495,7 @@ def get( :param host_group_name: The name of the dedicated host group. :type host_group_name: str :param expand: The expand expression to apply on the operation. The response shows the list of - instance view of the dedicated hosts under the dedicated host group. Possible values are + instance view of the dedicated hosts under the dedicated host group. Known values are "instanceView" or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -485,13 +503,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -501,11 +522,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -531,7 +554,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -544,13 +567,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -559,9 +585,11 @@ def prepare_request(next_link=None): 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: @@ -570,9 +598,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -609,7 +639,7 @@ def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -620,13 +650,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -634,9 +667,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -644,9 +679,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_dedicated_hosts_operations.py index 27f2bef30a1a..36d7590b62f3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHost] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_by_host_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_by_host_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostsOperations(object): - """DedicatedHostsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -341,17 +348,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -359,20 +369,27 @@ def begin_create_or_update( 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('DedicatedHost', 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( @@ -390,17 +407,20 @@ def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -413,11 +433,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -444,9 +466,9 @@ def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -470,17 +492,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -488,20 +513,27 @@ def begin_update( 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('DedicatedHost', 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( @@ -521,13 +553,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements host_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -537,11 +572,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -586,21 +623,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -610,8 +652,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -632,7 +680,7 @@ def get( host_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -641,21 +689,24 @@ def get( :type host_group_name: str :param host_name: The name of the dedicated host. :type host_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedHost, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_06_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -666,11 +717,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +750,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostListResult"]: + ) -> Iterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -712,13 +765,16 @@ def list_by_host_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -728,9 +784,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -740,9 +798,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_images_operations.py index 0557d1b03bd9..e6ae081a8778 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -155,9 +157,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +174,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -192,9 +195,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -205,18 +211,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +229,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -237,58 +244,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -300,11 +306,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -334,9 +342,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -357,37 +365,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -404,17 +422,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -426,11 +447,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -460,9 +483,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -483,37 +506,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -532,13 +565,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -547,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,20 +631,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -616,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -637,7 +686,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -651,13 +700,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -667,11 +719,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -707,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -722,9 +779,11 @@ def prepare_request(next_link=None): 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: @@ -733,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -772,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -781,13 +842,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -805,9 +871,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_log_analytics_operations.py index 4cb58ae571f6..41e2a228ca10 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_operations.py index 02c413057227..86b0c222fb75 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_proximity_placement_groups_operations.py index 6adc9bb65f9d..51888fda35aa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( include_colocation_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +172,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if include_colocation_status is not None: - _query_parameters['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -189,9 +192,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -235,51 +242,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -293,14 +296,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -312,11 +318,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -346,9 +354,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -362,14 +370,17 @@ def update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -381,11 +392,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -424,13 +437,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -439,11 +455,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -467,7 +485,7 @@ def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -482,13 +500,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -498,11 +519,13 @@ def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +550,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -537,13 +560,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -551,9 +577,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -561,9 +589,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -601,7 +631,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -613,13 +643,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -628,9 +661,11 @@ def prepare_request(next_link=None): 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: @@ -639,9 +674,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_ssh_public_keys_operations.py index 101280d47a5d..92f18e7559fa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_ssh_public_keys_operations.py @@ -16,12 +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 .. 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,9 +31,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") path_format_arguments = { @@ -43,18 +46,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -64,9 +65,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys") # pylint: disable=line-too-long path_format_arguments = { @@ -77,18 +81,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -98,14 +100,17 @@ def build_create_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -117,20 +122,18 @@ def build_create_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -142,14 +145,17 @@ def build_update_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyUpdateResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -161,20 +167,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -187,8 +191,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -200,13 +205,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -217,9 +221,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -231,18 +238,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -253,9 +258,12 @@ def build_generate_key_pair_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair") # pylint: disable=line-too-long path_format_arguments = { @@ -267,48 +275,44 @@ def build_generate_key_pair_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class SshPublicKeysOperations(object): - """SshPublicKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -319,13 +323,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -333,9 +340,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -343,9 +352,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -383,7 +394,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -396,13 +407,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -411,9 +425,11 @@ def prepare_request(next_link=None): 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: @@ -422,9 +438,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -462,9 +480,9 @@ def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -478,14 +496,17 @@ def create( :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -497,11 +518,13 @@ def create( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -531,9 +554,9 @@ def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -547,14 +570,17 @@ def update( :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -566,11 +592,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -609,13 +637,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -624,11 +655,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -651,7 +684,7 @@ def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -663,13 +696,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -678,11 +714,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -709,7 +747,7 @@ def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -723,13 +761,16 @@ def generate_key_pair( :rtype: ~azure.mgmt.compute.v2020_06_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -738,11 +779,13 @@ def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_usage_operations.py index a5d20da73acb..ea66960d71f8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_extension_images_operations.py index cafeb96d7b4b..6d302e58ecf9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_extensions_operations.py index 26e2308a73d8..f31c4f982a8d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,8 +129,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -141,13 +144,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -161,9 +163,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -176,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -202,9 +205,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -216,61 +222,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -283,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -318,9 +325,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -347,17 +354,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -365,20 +375,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -396,17 +413,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -419,11 +439,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,9 +472,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -479,17 +501,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -497,20 +522,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -530,13 +562,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -546,11 +581,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,21 +632,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -619,8 +661,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -641,7 +689,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -657,13 +705,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -674,11 +725,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -706,7 +759,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -720,13 +773,16 @@ def list( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -736,11 +792,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_images_operations.py index dfea888868d2..29a1357f605c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_run_commands_operations.py index 009fbb61643a..681316d33d64 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -69,9 +70,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -83,18 +87,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -105,14 +107,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -125,20 +130,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -151,14 +154,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,20 +177,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -198,9 +202,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -213,18 +220,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -238,9 +243,12 @@ def build_get_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -253,20 +261,18 @@ def build_get_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -279,9 +285,12 @@ def build_list_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -293,51 +302,47 @@ def build_list_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -349,13 +354,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +372,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -375,9 +385,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -416,7 +428,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -428,13 +440,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -443,11 +458,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -473,18 +490,21 @@ def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -497,11 +517,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,11 +554,11 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -548,7 +570,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -565,16 +587,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -582,20 +607,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -613,18 +645,21 @@ def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -637,11 +672,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -668,11 +705,11 @@ def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -683,7 +720,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -700,16 +737,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -717,20 +757,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -750,13 +797,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -766,11 +816,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,21 +867,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -839,8 +896,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -861,7 +924,7 @@ def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -877,13 +940,16 @@ def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -894,11 +960,13 @@ def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -926,7 +994,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -942,13 +1010,16 @@ def list_by_virtual_machine( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -959,9 +1030,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -972,9 +1045,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_extensions_operations.py index 4d62c350e393..78b4442fdf53 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -345,17 +352,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -363,20 +373,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -394,17 +411,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -417,11 +437,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +474,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -481,17 +503,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -499,20 +524,27 @@ def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -532,13 +564,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -548,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -597,21 +634,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -621,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -643,7 +691,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -659,13 +707,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -676,11 +727,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -707,7 +760,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -721,13 +774,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -737,9 +793,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -749,9 +807,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 7001630ee5a5..5390ba6edd86 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,8 +34,9 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -46,13 +48,12 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -63,8 +64,9 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -76,13 +78,12 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -93,8 +94,9 @@ def build_start_extension_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -106,13 +108,12 @@ def build_start_extension_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -123,9 +124,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -137,42 +141,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -180,13 +180,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -195,11 +198,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,20 +246,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -264,8 +274,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -284,13 +300,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -299,11 +318,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,20 +368,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -370,8 +396,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -390,13 +422,16 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -405,11 +440,13 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -453,20 +490,25 @@ def begin_start_extension_upgrade( # pylint: disable=inconsistent-return-statem :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_extension_upgrade_initial( + raw_result = self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -476,8 +518,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -496,7 +544,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -508,13 +556,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2020_06_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -523,11 +574,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py index 6f729c6c2524..af6a4ff53be1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -56,20 +59,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -83,14 +84,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -104,20 +108,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -132,9 +134,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -148,18 +153,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -174,9 +177,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -190,20 +196,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -217,9 +221,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -232,44 +239,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMExtensionsOperations(object): - """VirtualMachineScaleSetVMExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -277,17 +280,20 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -301,11 +307,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -368,17 +376,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -387,20 +398,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -419,17 +437,20 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -443,11 +464,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -475,9 +498,9 @@ def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -506,17 +529,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -525,20 +551,27 @@ def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -559,13 +592,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -576,11 +612,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -628,22 +666,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -653,8 +696,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -676,7 +725,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -694,13 +743,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -712,11 +764,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -745,7 +799,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -761,13 +815,16 @@ def list( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -778,11 +835,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index d42d89a0ff1a..2f73e6f4a903 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -133,9 +135,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -149,18 +154,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -175,9 +178,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -191,20 +197,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -218,9 +222,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -233,44 +240,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMRunCommandsOperations(object): - """VirtualMachineScaleSetVMRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -278,18 +281,21 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -303,11 +309,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -339,11 +347,11 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -356,7 +364,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -373,16 +381,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -423,18 +441,21 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,11 +503,11 @@ def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -497,7 +520,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -514,16 +537,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -532,20 +558,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -566,13 +599,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -583,11 +619,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,22 +673,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -660,8 +703,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -683,7 +732,7 @@ def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -701,13 +750,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_request( @@ -719,11 +771,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -752,7 +806,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -770,13 +824,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -788,9 +845,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -802,9 +861,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_vms_operations.py index bc1cc9c657cc..4db2447d02ae 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,13 +35,15 @@ def build_reimage_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -54,19 +56,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,8 +80,9 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -94,13 +95,12 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -112,8 +112,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -126,13 +127,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -143,14 +143,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -163,20 +166,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -190,8 +191,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -204,13 +206,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -224,9 +225,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -239,20 +243,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -264,9 +266,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -279,18 +284,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -305,9 +308,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -319,24 +325,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -350,8 +354,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -364,15 +369,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -384,8 +388,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -398,13 +403,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -416,8 +420,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -430,13 +435,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -448,8 +452,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -462,13 +467,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -482,9 +486,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -497,20 +504,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -522,8 +527,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -536,13 +542,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -554,8 +559,9 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -568,13 +574,12 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -585,14 +590,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -605,63 +613,62 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -677,11 +684,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -704,7 +713,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -731,17 +740,20 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -749,6 +761,8 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -758,8 +772,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -779,13 +799,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -795,11 +818,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -845,21 +870,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -869,8 +899,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -890,13 +926,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -906,11 +945,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -957,21 +998,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -981,8 +1027,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1000,17 +1052,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -1023,11 +1078,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1058,9 +1115,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1086,17 +1143,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1104,20 +1164,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1137,13 +1204,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1153,11 +1223,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1202,21 +1274,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1226,8 +1303,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1248,7 +1331,7 @@ def get( instance_id: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1257,21 +1340,24 @@ def get( :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. :type instance_id: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachineScaleSetVM, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1282,11 +1368,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1314,7 +1402,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1328,13 +1416,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1344,11 +1435,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1378,7 +1471,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1402,13 +1495,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1421,9 +1517,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1436,9 +1534,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1479,13 +1579,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1496,11 +1599,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1552,22 +1657,27 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1577,8 +1687,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1598,13 +1714,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1614,11 +1733,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1663,21 +1784,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1687,8 +1813,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1708,13 +1840,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1724,11 +1859,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1773,21 +1910,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1797,8 +1939,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1818,13 +1966,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1834,11 +1985,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1884,21 +2037,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1908,8 +2066,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1930,7 +2094,7 @@ def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -1949,13 +2113,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2020_06_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1966,11 +2133,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1998,13 +2167,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2014,11 +2186,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2063,21 +2237,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2087,8 +2266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2122,13 +2307,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2138,11 +2326,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2164,18 +2354,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2188,11 +2381,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2221,11 +2416,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2236,7 +2431,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2020_06_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2252,16 +2447,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2269,20 +2467,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_sets_operations.py index e16c86162b9d..8e1f0b4c5c51 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,18 +172,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -188,13 +191,15 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -206,19 +211,17 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -230,13 +233,15 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -248,19 +253,17 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -273,9 +276,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -287,18 +293,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -308,9 +312,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -321,18 +328,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -341,9 +346,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -353,18 +361,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -375,9 +381,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -389,18 +398,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -411,9 +418,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -425,18 +435,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -446,14 +454,16 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -465,21 +475,19 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -491,13 +499,15 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -509,19 +519,17 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -533,13 +541,15 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -551,19 +561,17 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -575,13 +583,15 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -593,19 +603,17 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -617,13 +625,15 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -635,19 +645,17 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -659,13 +667,15 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -677,19 +687,17 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -701,13 +709,15 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -719,19 +729,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -743,13 +751,15 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -761,19 +771,17 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -788,9 +796,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( platform_update_domain: int, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -802,19 +813,17 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -824,13 +833,15 @@ def build_convert_to_single_placement_group_request( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VMScaleSetConvertToSinglePlacementGroupInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup") # pylint: disable=line-too-long path_format_arguments = { @@ -842,19 +853,17 @@ def build_convert_to_single_placement_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -866,13 +875,15 @@ def build_set_orchestration_service_state_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.OrchestrationServiceStateInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState") # pylint: disable=line-too-long path_format_arguments = { @@ -884,61 +895,60 @@ def build_set_orchestration_service_state_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -950,11 +960,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -984,9 +996,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1009,37 +1021,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1056,17 +1078,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -1078,11 +1103,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1108,9 +1135,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1133,37 +1160,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1182,13 +1219,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1197,11 +1237,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1243,20 +1285,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1266,8 +1313,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1286,7 +1339,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1298,13 +1351,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1313,11 +1369,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1342,17 +1400,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1367,11 +1428,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1393,7 +1456,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1420,23 +1483,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1446,8 +1514,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1464,17 +1538,20 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1486,11 +1563,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1512,7 +1591,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Deletes virtual machines in a VM scale set. @@ -1536,23 +1615,28 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1562,8 +1646,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1582,7 +1672,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1594,13 +1684,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1609,11 +1702,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1639,7 +1734,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1651,13 +1746,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1666,9 +1764,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1677,9 +1777,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1716,7 +1818,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1728,13 +1830,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1742,9 +1847,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1752,9 +1859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1793,7 +1902,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1808,13 +1917,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1824,9 +1936,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1836,9 +1950,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1877,7 +1993,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1891,13 +2007,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1907,9 +2026,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1919,9 +2040,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1959,17 +2082,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1985,11 +2111,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2012,7 +2140,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -2043,17 +2171,20 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -2061,6 +2192,8 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2070,8 +2203,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2088,17 +2227,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2113,11 +2255,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2139,7 +2283,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2164,23 +2308,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2190,8 +2339,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2208,17 +2363,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2233,11 +2391,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2259,7 +2419,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2284,23 +2444,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2310,8 +2475,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2328,17 +2499,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2353,11 +2527,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2379,7 +2555,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2405,23 +2581,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2431,8 +2612,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2449,17 +2636,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2474,11 +2664,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2500,7 +2692,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2528,23 +2720,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2554,8 +2751,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2572,17 +2775,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2594,11 +2800,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2620,7 +2828,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2644,23 +2852,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2670,8 +2883,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2688,17 +2907,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -2713,11 +2935,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2739,7 +2963,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -2765,23 +2989,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2791,8 +3020,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2809,17 +3044,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2834,11 +3072,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2860,7 +3100,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2886,23 +3126,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2912,8 +3157,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2933,7 +3184,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2949,13 +3200,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2020_06_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2965,11 +3219,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2995,7 +3251,7 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -3012,14 +3268,17 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st :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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -3031,11 +3290,13 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3056,17 +3317,20 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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(parameters, 'OrchestrationServiceStateInput') @@ -3078,11 +3342,13 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3104,7 +3370,7 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> LROPoller[None]: """Changes ServiceState property for a given service. @@ -3127,23 +3393,28 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + 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._set_orchestration_service_state_initial( + raw_result = self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -3153,8 +3424,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_sizes_operations.py index 0d506b8f1e91..a3b59bad1904 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -99,13 +99,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machines_operations.py index d206d44fa3c5..a51f65e51735 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -203,8 +207,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -216,15 +221,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -237,9 +241,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -251,20 +258,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -275,9 +280,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -289,18 +297,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -311,8 +317,9 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -324,13 +331,12 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -341,8 +347,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -354,13 +361,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -371,8 +377,9 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -384,13 +391,12 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -400,9 +406,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -413,18 +422,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -435,9 +442,12 @@ def build_list_all_request( status_only: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -447,20 +457,18 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 status_only is not None: - _query_parameters['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') + _params['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -471,9 +479,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -485,18 +496,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -509,8 +518,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -522,15 +532,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -541,9 +550,12 @@ def build_reapply_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply") # pylint: disable=line-too-long path_format_arguments = { @@ -555,18 +567,16 @@ def build_reapply_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -577,8 +587,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -590,13 +601,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -607,8 +617,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -620,13 +631,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -637,8 +647,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -650,13 +661,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -666,13 +676,15 @@ def build_reimage_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -684,19 +696,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -711,9 +721,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -725,20 +738,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -749,8 +760,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -762,13 +774,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -779,8 +790,9 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -792,13 +804,12 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -809,9 +820,12 @@ def build_assess_patches_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = case_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-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -823,18 +837,16 @@ def build_assess_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -844,14 +856,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -863,53 +878,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2020_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.compute.v2020_06_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -921,13 +932,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -936,9 +950,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -947,9 +963,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -986,17 +1004,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -1008,11 +1029,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1040,9 +1063,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -1066,37 +1089,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -1113,17 +1146,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -1135,11 +1171,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1169,9 +1207,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -1194,37 +1232,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1241,17 +1289,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1263,11 +1314,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1297,9 +1350,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1321,37 +1374,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1371,13 +1434,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1387,11 +1453,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1437,21 +1505,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1461,8 +1534,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1482,28 +1561,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1513,11 +1595,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1544,7 +1628,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1556,13 +1640,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2020_06_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1571,11 +1658,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1602,13 +1691,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1617,11 +1709,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1664,20 +1758,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1687,8 +1786,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1707,13 +1812,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -1722,11 +1830,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1769,20 +1879,25 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1792,8 +1907,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1829,13 +1950,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1844,11 +1968,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1870,7 +1996,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1883,13 +2009,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1898,9 +2027,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1909,9 +2040,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1949,7 +2082,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1963,13 +2096,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1978,9 +2114,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1989,9 +2127,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2030,7 +2170,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -2045,13 +2185,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2061,9 +2204,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2073,9 +2218,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2115,13 +2262,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -2131,11 +2281,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2183,21 +2335,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2207,8 +2364,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2227,13 +2390,16 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -2242,11 +2408,13 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2288,20 +2456,25 @@ def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reapply_initial( + raw_result = self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2311,8 +2484,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2331,13 +2510,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2346,11 +2528,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2392,20 +2576,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2415,8 +2604,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2435,13 +2630,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2450,11 +2648,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2496,20 +2696,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2519,8 +2724,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2539,13 +2750,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2554,11 +2768,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2600,20 +2816,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2623,8 +2844,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2641,17 +2868,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -2666,11 +2896,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2692,7 +2924,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -2716,23 +2948,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -2742,8 +2979,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2763,7 +3006,7 @@ def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -2779,13 +3022,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2020_06_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -2795,11 +3041,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2826,13 +3074,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2841,11 +3092,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2887,20 +3140,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2910,8 +3168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2942,13 +3206,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2957,11 +3224,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2983,14 +3252,17 @@ def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -2999,11 +3271,13 @@ def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3032,7 +3306,7 @@ def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -3053,34 +3327,44 @@ def begin_assess_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -3097,18 +3381,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -3120,11 +3407,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3152,11 +3441,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -3165,7 +3454,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2020_06_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -3181,36 +3470,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/__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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/_compute_management_client.py index d096c3b92476..d2bed40e4275 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/_compute_management_client.py @@ -62,10 +62,18 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/_compute_management_client.py index 0a931a0fcfd2..af5a91535c5e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/_compute_management_client.py @@ -62,10 +62,18 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/__init__.py index 22cffb20eb1d..057394001370 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/__init__.py @@ -11,9 +11,14 @@ from ._disk_encryption_sets_operations import DiskEncryptionSetsOperations from ._disk_accesses_operations import DiskAccessesOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', 'DiskEncryptionSetsOperations', 'DiskAccessesOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_disk_accesses_operations.py index d86dabc3f1d5..c7f43b842163 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskAccessesOperations: - """DiskAccessesOperations async operations. - - You 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.compute.v2020_06_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_06_30.aio.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_30.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_30.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_30.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -340,11 +372,13 @@ async def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-06-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_30.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_30.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -626,7 +690,7 @@ async def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -640,13 +704,16 @@ async def get_private_link_resources( :rtype: ~azure.mgmt.compute.v2020_06_30.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', "2020-06-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -655,11 +722,13 @@ async def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_disk_encryption_sets_operations.py index 53ac65821e68..7e704302f0b5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskEncryptionSetsOperations: - """DiskEncryptionSetsOperations async operations. - - You 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.compute.v2020_06_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_06_30.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -238,9 +257,9 @@ async def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -266,37 +285,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -315,7 +344,7 @@ async def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -329,13 +358,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -344,11 +376,13 @@ async def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -375,13 +409,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -390,11 +427,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,20 +477,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-06-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -461,8 +505,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -480,7 +530,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -492,13 +542,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -507,9 +560,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -518,9 +573,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -557,7 +614,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -567,13 +624,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -581,9 +641,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -591,9 +653,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -632,7 +696,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceUriList"]: + ) -> AsyncIterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -647,13 +711,16 @@ def list_associated_resources( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_30.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -663,9 +730,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_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,9 +744,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_disks_operations.py index d44a812dcbc4..cd807663d391 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2020_06_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_06_30.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_30.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-06-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-06-30")) # 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_snapshots_operations.py index cdf8b9b58476..002885e779f7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2020_06_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_06_30.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_06_30.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-06-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_06_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_06_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-06-30")) # 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/__init__.py index 224ec0c0219e..22371af1ac29 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/__init__.py @@ -59,7 +59,9 @@ PrivateEndpointServiceConnectionStatus, SnapshotStorageAccountTypes, ) - +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__ = [ 'AccessUri', 'ApiError', @@ -111,3 +113,5 @@ 'PrivateEndpointServiceConnectionStatus', 'SnapshotStorageAccountTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/_compute_management_client_enums.py index 56c11da4bb87..3b30b8f8d3e2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/_compute_management_client_enums.py @@ -7,17 +7,16 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" WRITE = "Write" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -40,13 +39,13 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the disk. UPLOAD = "Upload" -class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported. """ SYSTEM_ASSIGNED = "SystemAssigned" -class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -57,7 +56,7 @@ class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: of the keys is Customer managed and the other key is Platform managed. ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" -class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible state of the disk. """ @@ -74,7 +73,7 @@ class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: A disk is created for upload and a write token has been issued for uploading to it. ACTIVE_UPLOAD = "ActiveUpload" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -89,7 +88,7 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: databases (for example, SQL, Oracle), and other transaction-heavy workloads. ULTRA_SSD_LRS = "UltraSSD_LRS" -class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -103,14 +102,14 @@ class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the other key is Platform managed. ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Policy for accessing the disk via network. """ @@ -121,14 +120,14 @@ class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The disk cannot be exported. DENY_ALL = "DenyAll" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -137,7 +136,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. """ @@ -145,7 +144,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/_models_py3.py index 4b11c6c8295f..b245f4227380 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -66,8 +68,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -139,8 +141,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :vartype create_option: str or ~azure.mgmt.compute.v2020_06_30.models.DiskCreateOption :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -189,10 +191,10 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, - gallery_image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, + gallery_image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, upload_size_bytes: Optional[int] = None, @@ -201,7 +203,7 @@ def __init__( ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :paramtype create_option: str or ~azure.mgmt.compute.v2020_06_30.models.DiskCreateOption :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -323,10 +325,10 @@ class Disk(Resource): :vartype zones: list[str] :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_06_30.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_30.models.HyperVGeneration :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -360,7 +362,7 @@ class Disk(Resource): mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. :vartype disk_m_bps_read_only: long - :ivar disk_state: The state of the disk. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", "Reserved", "ActiveSAS", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2020_06_30.models.DiskState :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed @@ -372,8 +374,8 @@ class Disk(Resource): :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should be set to a value greater than one for disks to allow attaching them to multiple VMs. :vartype share_info: list[~azure.mgmt.compute.v2020_06_30.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_06_30.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -436,20 +438,20 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - creation_data: Optional["CreationData"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, **kwargs @@ -464,10 +466,10 @@ def __init__( :paramtype sku: ~azure.mgmt.compute.v2020_06_30.models.DiskSku :keyword zones: The Logical zone list for Disk. :paramtype zones: list[str] - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_30.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_30.models.HyperVGeneration :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -501,8 +503,8 @@ def __init__( :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_06_30.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -631,7 +633,7 @@ class DiskAccessList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskAccess"], + value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs ): @@ -692,8 +694,8 @@ class DiskEncryptionSet(Resource): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2020_06_30.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype encryption_type: str or ~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSetType :ivar active_key: The key vault key which is currently used by this disk encryption set. :vartype active_key: ~azure.mgmt.compute.v2020_06_30.models.KeyVaultAndKeyReference @@ -732,9 +734,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyVaultAndKeyReference"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -745,8 +747,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2020_06_30.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype encryption_type: str or ~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSetType :keyword active_key: The key vault key which is currently used by this disk encryption set. :paramtype active_key: ~azure.mgmt.compute.v2020_06_30.models.KeyVaultAndKeyReference @@ -783,7 +785,7 @@ class DiskEncryptionSetList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskEncryptionSet"], + value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs ): @@ -804,8 +806,8 @@ class DiskEncryptionSetUpdate(msrest.serialization.Model): :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype encryption_type: str or ~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSetType :ivar active_key: Key Vault Key Url and vault id of KeK, KeK is optional and when provided is used to unwrap the encryptionKey. @@ -822,15 +824,15 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyVaultAndKeyReference"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype encryption_type: str or ~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSetType :keyword active_key: Key Vault Key Url and vault id of KeK, KeK is optional and when provided is used to unwrap the encryptionKey. @@ -866,7 +868,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -887,8 +889,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS". :vartype name: str or ~azure.mgmt.compute.v2020_06_30.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -906,11 +908,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype name: str or ~azure.mgmt.compute.v2020_06_30.models.DiskStorageAccountTypes """ @@ -927,7 +929,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :vartype sku: ~azure.mgmt.compute.v2020_06_30.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_06_30.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -958,8 +960,8 @@ class DiskUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2020_06_30.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_06_30.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -991,17 +993,17 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, max_shares: Optional[int] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, **kwargs @@ -1012,7 +1014,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :paramtype sku: ~azure.mgmt.compute.v2020_06_30.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_30.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1043,8 +1045,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2020_06_30.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_06_30.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -1078,7 +1080,7 @@ class Encryption(msrest.serialization.Model): :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Possible values include: + :ivar type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype type: str or ~azure.mgmt.compute.v2020_06_30.models.EncryptionType @@ -1093,14 +1095,14 @@ def __init__( self, *, disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "EncryptionType"]] = None, + type: Optional[Union[str, "_models.EncryptionType"]] = None, **kwargs ): """ :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Possible values include: + :keyword type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype type: str or ~azure.mgmt.compute.v2020_06_30.models.EncryptionType @@ -1116,7 +1118,7 @@ class EncryptionSetIdentity(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is - supported. Possible values include: "SystemAssigned". + supported. Known values are: "SystemAssigned". :vartype type: str or ~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSetIdentityType :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a @@ -1142,12 +1144,12 @@ class EncryptionSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "DiskEncryptionSetIdentityType"]] = None, + type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, **kwargs ): """ :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned - is supported. Possible values include: "SystemAssigned". + is supported. Known values are: "SystemAssigned". :paramtype type: str or ~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSetIdentityType """ super(EncryptionSetIdentity, self).__init__(**kwargs) @@ -1189,7 +1191,7 @@ def __init__( self, *, enabled: bool, - encryption_settings: Optional[List["EncryptionSettingsElement"]] = None, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, encryption_settings_version: Optional[str] = None, **kwargs ): @@ -1231,8 +1233,8 @@ class EncryptionSettingsElement(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -1253,7 +1255,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read", "Write". + :ivar access: Required. Known values are: "None", "Read", "Write". :vartype access: str or ~azure.mgmt.compute.v2020_06_30.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -1272,12 +1274,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read", "Write". + :keyword access: Required. Known values are: "None", "Read", "Write". :paramtype access: str or ~azure.mgmt.compute.v2020_06_30.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -1385,7 +1387,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -1424,7 +1426,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -1484,7 +1486,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype private_link_service_connection_state: ~azure.mgmt.compute.v2020_06_30.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.compute.v2020_06_30.models.PrivateEndpointConnectionProvisioningState """ @@ -1508,8 +1510,8 @@ class PrivateEndpointConnection(msrest.serialization.Model): 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 ): """ @@ -1598,7 +1600,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -1613,7 +1615,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.compute.v2020_06_30.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -1632,14 +1634,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, actions_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.compute.v2020_06_30.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -1746,10 +1748,10 @@ class Snapshot(Resource): :vartype sku: ~azure.mgmt.compute.v2020_06_30.models.SnapshotSku :ivar time_created: The time when the snapshot was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_06_30.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_30.models.HyperVGeneration :ivar creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1761,7 +1763,7 @@ class Snapshot(Resource): :vartype disk_size_gb: int :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. :vartype disk_size_bytes: long - :ivar disk_state: The state of the snapshot. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the snapshot. Known values are: "Unattached", "Attached", "Reserved", "ActiveSAS", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2020_06_30.models.DiskState :ivar unique_id: Unique Guid identifying the resource. @@ -1778,8 +1780,8 @@ class Snapshot(Resource): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2020_06_30.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_06_30.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -1828,15 +1830,15 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, incremental: Optional[bool] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, **kwargs ): @@ -1847,10 +1849,10 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2020_06_30.models.SnapshotSku - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_30.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_06_30.models.HyperVGeneration :keyword creation_data: Disk source information. CreationData information cannot be changed after the disk has been created. @@ -1870,8 +1872,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2020_06_30.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_06_30.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -1921,7 +1923,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -1942,8 +1944,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2020_06_30.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -1961,12 +1962,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2020_06_30.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -1981,7 +1981,7 @@ class SnapshotUpdate(msrest.serialization.Model): :vartype tags: dict[str, str] :ivar sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :vartype sku: ~azure.mgmt.compute.v2020_06_30.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_06_30.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1995,8 +1995,8 @@ class SnapshotUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2020_06_30.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_06_30.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -2018,12 +2018,12 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, **kwargs ): @@ -2032,7 +2032,7 @@ def __init__( :paramtype tags: dict[str, str] :keyword sku: The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. :paramtype sku: ~azure.mgmt.compute.v2020_06_30.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_06_30.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -2046,8 +2046,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2020_06_30.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_06_30.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/__init__.py index 22cffb20eb1d..057394001370 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/__init__.py @@ -11,9 +11,14 @@ from ._disk_encryption_sets_operations import DiskEncryptionSetsOperations from ._disk_accesses_operations import DiskAccessesOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', 'DiskEncryptionSetsOperations', 'DiskAccessesOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_disk_accesses_operations.py index f9c2fe9a9a13..e972ea1c2db2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccess] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccessUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_get_private_link_resources_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,58 +284,57 @@ def build_get_private_link_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskAccessesOperations(object): - """DiskAccessesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_06_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_06_30.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -338,11 +346,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -372,9 +382,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -397,37 +407,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_30.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -444,17 +464,20 @@ def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -466,11 +489,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -500,9 +525,9 @@ def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -525,37 +550,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_30.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -574,7 +609,7 @@ def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -588,13 +623,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_30.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -603,11 +641,13 @@ def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -634,13 +674,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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', "2020-06-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -649,11 +692,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,20 +742,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-06-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -720,8 +770,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -739,7 +795,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -749,13 +805,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_30.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -764,9 +823,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -775,9 +836,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -814,7 +877,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -822,13 +885,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_30.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -836,9 +902,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -846,9 +914,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -887,7 +957,7 @@ def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -901,13 +971,16 @@ def get_private_link_resources( :rtype: ~azure.mgmt.compute.v2020_06_30.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', "2020-06-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -916,11 +989,13 @@ def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_disk_encryption_sets_operations.py index 2ff07274b6b3..c59566327535 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_list_associated_resources_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,58 +284,57 @@ def build_list_associated_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskEncryptionSetsOperations(object): - """DiskEncryptionSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_06_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_06_30.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -338,11 +346,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -372,9 +382,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -399,37 +409,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -446,17 +466,20 @@ def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -468,11 +491,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,9 +527,9 @@ def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -529,37 +554,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -578,7 +613,7 @@ def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -592,13 +627,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -607,11 +645,13 @@ def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -638,13 +678,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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', "2020-06-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -653,11 +696,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -701,20 +746,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-06-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -724,8 +774,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -743,7 +799,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -755,13 +811,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -770,9 +829,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -781,9 +842,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -820,7 +883,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -830,13 +893,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_30.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -844,9 +910,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -854,9 +922,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -895,7 +965,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> Iterable["_models.ResourceUriList"]: + ) -> Iterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -909,13 +979,16 @@ def list_associated_resources( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_30.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -925,9 +998,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -937,9 +1012,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_disks_operations.py index 5c4c8bf5ce0d..a8b02f04182f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_06_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_06_30.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_30.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-06-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2020-06-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-06-30")) # 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_snapshots_operations.py index 1c6f99af34b4..2576a0273410 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_06_30/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = case_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-06-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_06_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_06_30.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_06_30.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-06-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_06_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_06_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-06-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2020-06-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-06-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-06-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-06-30")) # 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/__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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/_compute_management_client.py index d7d84ec5de05..2e76ffd9f588 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/_compute_management_client.py @@ -89,20 +89,48 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_restore_point = DiskRestorePointOperations(self._client, self._config, self._serialize, self._deserialize) - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_sharing_profile = GallerySharingProfileOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_galleries = SharedGalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_gallery_images = SharedGalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_sharing_profile = GallerySharingProfileOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_galleries = SharedGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_images = SharedGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/_compute_management_client.py index aa38461e01b6..62d719aa825f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/_compute_management_client.py @@ -90,20 +90,48 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_restore_point = DiskRestorePointOperations(self._client, self._config, self._serialize, self._deserialize) - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_sharing_profile = GallerySharingProfileOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_galleries = SharedGalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_gallery_images = SharedGalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_sharing_profile = GallerySharingProfileOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_galleries = SharedGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_images = SharedGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/__init__.py index fa8761318cfa..2f4d2e8ca379 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/__init__.py @@ -21,6 +21,9 @@ from ._shared_gallery_images_operations import SharedGalleryImagesOperations from ._shared_gallery_image_versions_operations import SharedGalleryImageVersionsOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', @@ -37,3 +40,5 @@ 'SharedGalleryImagesOperations', 'SharedGalleryImageVersionsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disk_accesses_operations.py index 1f311492fdb6..d4fb49982aa1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskAccessesOperations: - """DiskAccessesOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -340,11 +372,13 @@ async def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -626,7 +690,7 @@ async def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -640,13 +704,16 @@ async def get_private_link_resources( :rtype: ~azure.mgmt.compute.v2020_09_30.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', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -655,11 +722,13 @@ async def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -685,17 +754,20 @@ async def _update_a_private_endpoint_connection_initial( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: 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(private_endpoint_connection, 'PrivateEndpointConnection') @@ -708,11 +780,13 @@ async def _update_a_private_endpoint_connection_initial( content_type=content_type, json=_json, template_url=self._update_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -743,9 +817,9 @@ async def begin_update_a_private_endpoint_connection( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection under disk access resource, this can't be used to create a new private endpoint connection. @@ -775,17 +849,20 @@ async def begin_update_a_private_endpoint_connection( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: 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] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_a_private_endpoint_connection_initial( + raw_result = await self._update_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -793,20 +870,27 @@ async def begin_update_a_private_endpoint_connection( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -826,7 +910,7 @@ async def get_a_private_endpoint_connection( disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about a private endpoint connection under a disk access resource. :param resource_group_name: The name of the resource group. @@ -842,13 +926,16 @@ async def get_a_private_endpoint_connection( :rtype: ~azure.mgmt.compute.v2020_09_30.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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_a_private_endpoint_connection_request( @@ -858,11 +945,13 @@ async def get_a_private_endpoint_connection( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get_a_private_endpoint_connection.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -890,13 +979,16 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inco private_endpoint_connection_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', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_a_private_endpoint_connection_request_initial( @@ -906,11 +998,13 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inco private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -957,21 +1051,26 @@ async def begin_delete_a_private_endpoint_connection( # pylint: disable=inconsi :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_a_private_endpoint_connection_initial( + raw_result = await self._delete_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -981,8 +1080,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1001,7 +1106,7 @@ def list_private_endpoint_connections( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List information about private endpoint connections under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1017,13 +1122,16 @@ def list_private_endpoint_connections( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - 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: @@ -1033,9 +1141,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=self.list_private_endpoint_connections.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1045,9 +1155,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disk_encryption_sets_operations.py index 0339aa0ef7d4..504fecc3cf37 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskEncryptionSetsOperations: - """DiskEncryptionSetsOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -238,9 +257,9 @@ async def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -266,37 +285,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -315,7 +344,7 @@ async def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -329,13 +358,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -344,11 +376,13 @@ async def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -375,13 +409,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -390,11 +427,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,20 +477,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -461,8 +505,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -480,7 +530,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -492,13 +542,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -507,9 +560,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -518,9 +573,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -557,7 +614,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -567,13 +624,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -581,9 +641,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -591,9 +653,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -632,7 +696,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceUriList"]: + ) -> AsyncIterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -647,13 +711,16 @@ def list_associated_resources( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -663,9 +730,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_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,9 +744,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disk_restore_point_operations.py index 343ca472801b..b48e1e81afc0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disk_restore_point_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskRestorePointOperations: - """DiskRestorePointOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +52,7 @@ async def get( vm_restore_point_name: str, disk_restore_point_name: str, **kwargs: Any - ) -> "_models.DiskRestorePoint": + ) -> _models.DiskRestorePoint: """Get disk restorePoint resource. :param resource_group_name: The name of the resource group. @@ -74,13 +73,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.DiskRestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePoint] request = build_get_request( @@ -91,11 +93,13 @@ async def get( disk_restore_point_name=disk_restore_point_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -123,7 +127,7 @@ def list_by_restore_point( restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskRestorePointList"]: + ) -> AsyncIterable[_models.DiskRestorePointList]: """Lists diskRestorePoints under a vmRestorePoint. :param resource_group_name: The name of the resource group. @@ -143,13 +147,16 @@ def list_by_restore_point( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskRestorePointList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePointList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePointList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -160,9 +167,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=self.list_by_restore_point.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -173,9 +182,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disks_operations.py index 794f6957d4cf..8eae0803d76b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_galleries_operations.py index 466f05416552..ca648ff8738f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleriesOperations: - """GalleriesOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'GalleryUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -234,9 +253,9 @@ async def begin_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -259,37 +278,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -309,7 +338,7 @@ async def get( gallery_name: str, select: Optional[Union[str, "_models.SelectPermissions"]] = None, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -339,11 +371,13 @@ async def get( api_version=api_version, select=select, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -370,13 +404,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -385,11 +422,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -431,20 +470,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -454,8 +498,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -473,7 +523,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -484,13 +534,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +552,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -510,9 +565,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -549,7 +606,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -558,13 +615,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -572,9 +632,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -582,9 +644,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_application_versions_operations.py index f9190000e77c..0e15c6362043 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationVersionsOperations: - """GalleryApplicationVersionsOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -152,17 +156,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -171,20 +178,27 @@ async def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -203,17 +217,20 @@ async def _update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersionUpdate') @@ -227,11 +244,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -259,9 +278,9 @@ async def begin_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -295,17 +314,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -314,20 +336,27 @@ async def begin_update( 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('GalleryApplicationVersion', 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( @@ -349,7 +378,7 @@ async def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -370,13 +399,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -388,11 +420,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -421,13 +455,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -438,11 +475,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -493,22 +532,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -518,8 +562,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -539,7 +589,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationVersionList"]: + ) -> AsyncIterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -557,13 +607,16 @@ def list_by_gallery_application( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -574,9 +627,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -587,9 +642,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_applications_operations.py index 26ffd8aab9fd..e798b4c0ab50 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationsOperations: - """GalleryApplicationsOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -144,17 +148,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -162,20 +169,27 @@ async def begin_create_or_update( 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('GalleryApplication', 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( @@ -193,17 +207,20 @@ async def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplicationUpdate') @@ -216,11 +233,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -277,17 +296,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -295,20 +317,27 @@ async def begin_update( 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('GalleryApplication', 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( @@ -328,7 +357,7 @@ async def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -344,13 +373,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -360,11 +392,13 @@ async def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,13 +426,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -408,11 +445,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,21 +497,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -482,8 +526,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -502,7 +552,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationList"]: + ) -> AsyncIterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -517,13 +567,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -533,9 +586,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -545,9 +600,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_image_versions_operations.py index 8b32cd038c33..2ef39f3a50b4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImageVersionsOperations: - """GalleryImageVersionsOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Create or update a gallery image version. :param resource_group_name: The name of the resource group. @@ -151,17 +155,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -170,20 +177,27 @@ async def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -202,17 +216,20 @@ async def _update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersionUpdate') @@ -226,11 +243,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -258,9 +277,9 @@ async def begin_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Update a gallery image version. :param resource_group_name: The name of the resource group. @@ -293,17 +312,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -312,20 +334,27 @@ async def begin_update( 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('GalleryImageVersion', 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( @@ -347,7 +376,7 @@ async def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery image version. :param resource_group_name: The name of the resource group. @@ -367,13 +396,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -385,11 +417,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -418,13 +452,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -435,11 +472,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -489,22 +528,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -514,8 +558,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -535,7 +585,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageVersionList"]: + ) -> AsyncIterable[_models.GalleryImageVersionList]: """List gallery image versions in a gallery image definition. :param resource_group_name: The name of the resource group. @@ -553,13 +603,16 @@ def list_by_gallery_image( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +623,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +638,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_images_operations.py index 18d5c62e9743..9eb776a7958f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImagesOperations: - """GalleryImagesOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Create or update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -160,20 +167,27 @@ async def begin_create_or_update( 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('GalleryImage', 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( @@ -191,17 +205,20 @@ async def _update_initial( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImageUpdate') @@ -214,11 +231,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -245,9 +264,9 @@ async def begin_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -274,17 +293,20 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -292,20 +314,27 @@ async def begin_update( 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('GalleryImage', 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( @@ -325,7 +354,7 @@ async def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery image definition. :param resource_group_name: The name of the resource group. @@ -340,13 +369,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -356,11 +388,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -388,13 +422,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -404,11 +441,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -454,21 +493,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -478,8 +522,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -498,7 +548,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageList"]: + ) -> AsyncIterable[_models.GalleryImageList]: """List gallery image definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -512,13 +562,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -528,9 +581,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -540,9 +595,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_sharing_profile_operations.py index e6b33f708c7f..318eeb8cb9bc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_sharing_profile_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_gallery_sharing_profile_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,42 +25,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GallerySharingProfileOperations: - """GallerySharingProfileOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`gallery_sharing_profile` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _update_initial( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> "_models.SharingUpdate": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] + ) -> _models.SharingUpdate: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharingUpdate] _json = self._serialize.body(sharing_update, 'SharingUpdate') @@ -71,11 +73,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,9 +109,9 @@ async def begin_update( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.SharingUpdate"]: + ) -> AsyncLROPoller[_models.SharingUpdate]: """Update sharing profile of a gallery. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.SharingUpdate] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharingUpdate] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, sharing_update=sharing_update, 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('SharingUpdate', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_shared_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_shared_galleries_operations.py index 58d1ba789691..2ae1230cb224 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_shared_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_shared_galleries_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SharedGalleriesOperations: - """SharedGalleriesOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`shared_galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -51,7 +50,7 @@ def list( location: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.SharedGalleryList"]: + ) -> AsyncIterable[_models.SharedGalleryList]: """List shared galleries by subscription id or tenant id. :param location: Resource location. @@ -65,13 +64,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.SharedGalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +83,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -93,9 +97,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +140,7 @@ async def get( location: str, gallery_unique_name: str, **kwargs: Any - ) -> "_models.SharedGallery": + ) -> _models.SharedGallery: """Get a shared gallery by subscription id or tenant id. :param location: Resource location. @@ -146,13 +152,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.SharedGallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGallery] request = build_get_request( @@ -161,11 +170,13 @@ async def get( gallery_unique_name=gallery_unique_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_shared_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_shared_gallery_image_versions_operations.py index bdbc4cf31ff5..9b81698b04c4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_shared_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_shared_gallery_image_versions_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SharedGalleryImageVersionsOperations: - """SharedGalleryImageVersionsOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`shared_gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -53,7 +52,7 @@ def list( gallery_image_name: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.SharedGalleryImageVersionList"]: + ) -> AsyncIterable[_models.SharedGalleryImageVersionList]: """List shared gallery image versions by subscription id or tenant id. :param location: Resource location. @@ -73,13 +72,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.SharedGalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +93,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_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,9 +109,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -148,7 +154,7 @@ async def get( gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any - ) -> "_models.SharedGalleryImageVersion": + ) -> _models.SharedGalleryImageVersion: """Get a shared gallery image version by subscription id or tenant id. :param location: Resource location. @@ -168,13 +174,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.SharedGalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageVersion] request = build_get_request( @@ -185,11 +194,13 @@ async def get( gallery_image_version_name=gallery_image_version_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_shared_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_shared_gallery_images_operations.py index 79c74f9983ba..69219bd95ddd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_shared_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_shared_gallery_images_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SharedGalleryImagesOperations: - """SharedGalleryImagesOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`shared_gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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 +51,7 @@ def list( gallery_unique_name: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.SharedGalleryImageList"]: + ) -> AsyncIterable[_models.SharedGalleryImageList]: """List shared gallery images by subscription id or tenant id. :param location: Resource location. @@ -69,13 +68,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.SharedGalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -86,9 +88,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -99,9 +103,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -141,7 +147,7 @@ async def get( gallery_unique_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.SharedGalleryImage": + ) -> _models.SharedGalleryImage: """Get a shared gallery image by subscription id or tenant id. :param location: Resource location. @@ -156,13 +162,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.SharedGalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImage] request = build_get_request( @@ -172,11 +181,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_snapshots_operations.py index f40435668354..c5f70877b814 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_09_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_09_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/__init__.py index 525c5bbca1ca..01defec9c99b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/__init__.py @@ -135,7 +135,9 @@ SnapshotStorageAccountTypes, StorageAccountType, ) - +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__ = [ 'AccessUri', 'ApiError', @@ -263,3 +265,5 @@ 'SnapshotStorageAccountTypes', 'StorageAccountType', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/_compute_management_client_enums.py index e741f7310aca..3af3e8d95ca9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/_compute_management_client_enums.py @@ -7,17 +7,16 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" WRITE = "Write" -class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the aggregated replication status based on all the regional replication status flags. """ @@ -26,7 +25,7 @@ class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, En COMPLETED = "Completed" FAILED = "Failed" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -49,7 +48,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the disk. UPLOAD = "Upload" -class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted resources @@ -59,7 +58,7 @@ class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, SYSTEM_ASSIGNED = "SystemAssigned" NONE = "None" -class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -70,7 +69,7 @@ class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: of the keys is Customer managed and the other key is Platform managed. ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" -class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible state of the disk. """ @@ -87,7 +86,7 @@ class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: A disk is created for upload and a write token has been issued for uploading to it. ACTIVE_UPLOAD = "ActiveUpload" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -102,7 +101,7 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: databases (for example, SQL, Oracle), and other transaction-heavy workloads. ULTRA_SSD_LRS = "UltraSSD_LRS" -class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -116,13 +115,13 @@ class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the other key is Platform managed. ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class GalleryApplicationVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryApplicationVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -133,7 +132,7 @@ class GalleryApplicationVersionPropertiesProvisioningState(with_metaclass(CaseIn DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImagePropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -144,7 +143,7 @@ class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnum DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImageVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -155,7 +154,7 @@ class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensit DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -166,7 +165,7 @@ class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, DELETING = "Deleting" MIGRATING = "Migrating" -class GallerySharingPermissionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GallerySharingPermissionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the permission of sharing gallery. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Private** :code:`
`:code:`
` **Groups** """ @@ -174,7 +173,7 @@ class GallerySharingPermissionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, PRIVATE = "Private" GROUPS = "Groups" -class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite' """ @@ -182,14 +181,14 @@ class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Policy for accessing the disk via network. """ @@ -200,7 +199,7 @@ class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The disk cannot be exported. DENY_ALL = "DenyAll" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows the user to specify whether the virtual machines created under this image are 'Generalized' or 'Specialized'. """ @@ -208,14 +207,14 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu GENERALIZED = "Generalized" SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -224,7 +223,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. """ @@ -232,7 +231,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the regional replication state. """ @@ -241,19 +240,19 @@ class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAILED = "Failed" -class ReplicationStatusTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): REPLICATION_STATUS = "ReplicationStatus" -class SelectPermissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SelectPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): PERMISSIONS = "Permissions" -class SharedToValues(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharedToValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): TENANT = "tenant" -class SharingProfileGroupTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharingProfileGroupTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the type of sharing group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Subscriptions** :code:`
`:code:`
` **AADTenants** @@ -262,7 +261,7 @@ class SharingProfileGroupTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum SUBSCRIPTIONS = "Subscriptions" AAD_TENANTS = "AADTenants" -class SharingUpdateOperationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharingUpdateOperationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the operation type of gallery sharing update. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset** @@ -272,7 +271,7 @@ class SharingUpdateOperationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E REMOVE = "Remove" RESET = "Reset" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -283,7 +282,7 @@ class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E #: Standard zone redundant storage. STANDARD_ZRS = "Standard_ZRS" -class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type to be used to store the image. This property is not updatable. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/_models_py3.py index 11de601d220a..7577327b8191 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -67,8 +69,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -140,8 +142,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :vartype create_option: str or ~azure.mgmt.compute.v2020_09_30.models.DiskCreateOption :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -190,10 +192,10 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, - gallery_image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, + gallery_image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, upload_size_bytes: Optional[int] = None, @@ -202,7 +204,7 @@ def __init__( ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :paramtype create_option: str or ~azure.mgmt.compute.v2020_09_30.models.DiskCreateOption :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -422,10 +424,10 @@ class Disk(Resource): :vartype extended_location: ~azure.mgmt.compute.v2020_09_30.models.ExtendedLocation :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_09_30.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: @@ -463,7 +465,7 @@ class Disk(Resource): mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. :vartype disk_m_bps_read_only: long - :ivar disk_state: The state of the disk. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", "Reserved", "ActiveSAS", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2020_09_30.models.DiskState :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed @@ -475,8 +477,8 @@ class Disk(Resource): :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should be set to a value greater than one for disks to allow attaching them to multiple VMs. :vartype share_info: list[~azure.mgmt.compute.v2020_09_30.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_09_30.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -545,22 +547,22 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - creation_data: Optional["CreationData"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, @@ -579,10 +581,10 @@ def __init__( :keyword extended_location: The extended location where the disk will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2020_09_30.models.ExtendedLocation - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_09_30.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: @@ -620,8 +622,8 @@ def __init__( :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_09_30.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -756,7 +758,7 @@ class DiskAccessList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskAccess"], + value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs ): @@ -817,8 +819,8 @@ class DiskEncryptionSet(Resource): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2020_09_30.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype encryption_type: str or ~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSetType :ivar active_key: The key vault key which is currently used by this disk encryption set. :vartype active_key: ~azure.mgmt.compute.v2020_09_30.models.KeyForDiskEncryptionSet @@ -857,9 +859,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyForDiskEncryptionSet"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, **kwargs ): """ @@ -870,8 +872,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2020_09_30.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype encryption_type: str or ~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSetType :keyword active_key: The key vault key which is currently used by this disk encryption set. :paramtype active_key: ~azure.mgmt.compute.v2020_09_30.models.KeyForDiskEncryptionSet @@ -908,7 +910,7 @@ class DiskEncryptionSetList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskEncryptionSet"], + value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs ): @@ -929,8 +931,8 @@ class DiskEncryptionSetUpdate(msrest.serialization.Model): :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype encryption_type: str or ~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSetType :ivar active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and Snapshots. @@ -947,15 +949,15 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyForDiskEncryptionSet"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, **kwargs ): """ :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype encryption_type: str or ~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSetType :keyword active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and Snapshots. @@ -991,7 +993,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -1059,10 +1061,10 @@ class DiskRestorePoint(ProxyOnlyResource): :vartype time_created: ~datetime.datetime :ivar source_resource_id: arm id of source disk. :vartype source_resource_id: str - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_09_30.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. @@ -1105,13 +1107,13 @@ class DiskRestorePoint(ProxyOnlyResource): def __init__( self, *, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, **kwargs ): """ :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_09_30.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. @@ -1152,7 +1154,7 @@ class DiskRestorePointList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskRestorePoint"], + value: List["_models.DiskRestorePoint"], next_link: Optional[str] = None, **kwargs ): @@ -1173,8 +1175,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS". :vartype name: str or ~azure.mgmt.compute.v2020_09_30.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -1192,11 +1194,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS". :paramtype name: str or ~azure.mgmt.compute.v2020_09_30.models.DiskStorageAccountTypes """ @@ -1213,7 +1215,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :vartype sku: ~azure.mgmt.compute.v2020_09_30.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1244,8 +1246,8 @@ class DiskUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2020_09_30.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_09_30.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -1284,21 +1286,21 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, max_shares: Optional[int] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, - purchase_plan: Optional["PurchasePlan"] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, **kwargs ): """ @@ -1307,7 +1309,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS. :paramtype sku: ~azure.mgmt.compute.v2020_09_30.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1338,8 +1340,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2020_09_30.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_09_30.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -1380,7 +1382,7 @@ class Encryption(msrest.serialization.Model): :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Possible values include: + :ivar type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype type: str or ~azure.mgmt.compute.v2020_09_30.models.EncryptionType @@ -1395,14 +1397,14 @@ def __init__( self, *, disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "EncryptionType"]] = None, + type: Optional[Union[str, "_models.EncryptionType"]] = None, **kwargs ): """ :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Possible values include: + :keyword type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype type: str or ~azure.mgmt.compute.v2020_09_30.models.EncryptionType @@ -1429,8 +1431,8 @@ class EncryptionImages(msrest.serialization.Model): def __init__( self, *, - os_disk_image: Optional["OSDiskImageEncryption"] = None, - data_disk_images: Optional[List["DataDiskImageEncryption"]] = None, + os_disk_image: Optional["_models.OSDiskImageEncryption"] = None, + data_disk_images: Optional[List["_models.DataDiskImageEncryption"]] = None, **kwargs ): """ @@ -1453,7 +1455,7 @@ class EncryptionSetIdentity(msrest.serialization.Model): :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted - resources to lose access to the keys. Possible values include: "SystemAssigned", "None". + resources to lose access to the keys. Known values are: "SystemAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSetIdentityType :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a @@ -1479,15 +1481,14 @@ class EncryptionSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "DiskEncryptionSetIdentityType"]] = None, + type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, **kwargs ): """ :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the - encrypted resources to lose access to the keys. Possible values include: "SystemAssigned", - "None". + encrypted resources to lose access to the keys. Known values are: "SystemAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSetIdentityType """ super(EncryptionSetIdentity, self).__init__(**kwargs) @@ -1529,7 +1530,7 @@ def __init__( self, *, enabled: bool, - encryption_settings: Optional[List["EncryptionSettingsElement"]] = None, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, encryption_settings_version: Optional[str] = None, **kwargs ): @@ -1571,8 +1572,8 @@ class EncryptionSettingsElement(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -1593,7 +1594,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.compute.v2020_09_30.models.ExtendedLocationTypes """ @@ -1606,13 +1607,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.compute.v2020_09_30.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -1642,8 +1643,8 @@ class Gallery(Resource): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2020_09_30.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2020_09_30.models.GalleryPropertiesProvisioningState :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. @@ -1676,8 +1677,8 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, - sharing_profile: Optional["SharingProfile"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, + sharing_profile: Optional["_models.SharingProfile"] = None, **kwargs ): """ @@ -1731,8 +1732,8 @@ class GalleryApplication(Resource): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes """ @@ -1767,7 +1768,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -1789,8 +1790,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes """ @@ -1827,7 +1828,7 @@ class GalleryApplicationList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplication"], + value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs ): @@ -1916,8 +1917,8 @@ class GalleryApplicationUpdate(UpdateResourceDefinition): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes """ @@ -1949,7 +1950,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -1969,8 +1970,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes """ @@ -2003,8 +2004,8 @@ class GalleryApplicationVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationVersionPropertiesProvisioningState :ivar replication_status: This is the replication status of the gallery image version. @@ -2036,7 +2037,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -2078,7 +2079,7 @@ class GalleryApplicationVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplicationVersion"], + value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs ): @@ -2115,7 +2116,7 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_09_30.models.StorageAccountType """ @@ -2136,11 +2137,11 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, **kwargs ): """ @@ -2158,7 +2159,7 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_09_30.models.StorageAccountType @@ -2195,7 +2196,7 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_09_30.models.StorageAccountType :ivar source: Required. The source image from which the Image Version is going to be created. @@ -2226,13 +2227,13 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil def __init__( self, *, - source: "UserArtifactSource", - target_regions: Optional[List["TargetRegion"]] = None, + source: "_models.UserArtifactSource", + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - manage_actions: Optional["UserArtifactManage"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + manage_actions: Optional["_models.UserArtifactManage"] = None, enable_health_check: Optional[bool] = None, **kwargs ): @@ -2251,7 +2252,7 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_09_30.models.StorageAccountType @@ -2285,8 +2286,8 @@ class GalleryApplicationVersionUpdate(UpdateResourceDefinition): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationVersionPropertiesProvisioningState :ivar replication_status: This is the replication status of the gallery image version. @@ -2315,7 +2316,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -2351,7 +2352,7 @@ class GalleryArtifactSource(msrest.serialization.Model): def __init__( self, *, - managed_image: "ManagedArtifact", + managed_image: "_models.ManagedArtifact", **kwargs ): """ @@ -2406,7 +2407,7 @@ class GalleryDiskImage(msrest.serialization.Model): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2020_09_30.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2020_09_30.models.GalleryArtifactVersionSource @@ -2425,13 +2426,13 @@ class GalleryDiskImage(msrest.serialization.Model): def __init__( self, *, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2020_09_30.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2020_09_30.models.GalleryArtifactVersionSource @@ -2452,7 +2453,7 @@ class GalleryDataDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2020_09_30.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2020_09_30.models.GalleryArtifactVersionSource @@ -2478,13 +2479,13 @@ def __init__( self, *, lun: int, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2020_09_30.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2020_09_30.models.GalleryArtifactVersionSource @@ -2553,15 +2554,15 @@ class GalleryImage(Resource): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemStateTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_09_30.models.HyperVGeneration :ivar features: A list of gallery image features. :vartype features: list[~azure.mgmt.compute.v2020_09_30.models.GalleryImageFeature] @@ -2578,8 +2579,8 @@ class GalleryImage(Resource): :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2020_09_30.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2020_09_30.models.GalleryImagePropertiesProvisioningState """ @@ -2623,15 +2624,15 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - features: Optional[List["GalleryImageFeature"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, **kwargs ): """ @@ -2650,15 +2651,15 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemStateTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_09_30.models.HyperVGeneration :keyword features: A list of gallery image features. :paramtype features: list[~azure.mgmt.compute.v2020_09_30.models.GalleryImageFeature] @@ -2796,7 +2797,7 @@ class GalleryImageList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImage"], + value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs ): @@ -2836,15 +2837,15 @@ class GalleryImageUpdate(UpdateResourceDefinition): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemStateTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_09_30.models.HyperVGeneration :ivar features: A list of gallery image features. :vartype features: list[~azure.mgmt.compute.v2020_09_30.models.GalleryImageFeature] @@ -2861,8 +2862,8 @@ class GalleryImageUpdate(UpdateResourceDefinition): :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2020_09_30.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2020_09_30.models.GalleryImagePropertiesProvisioningState """ @@ -2903,15 +2904,15 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - features: Optional[List["GalleryImageFeature"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, **kwargs ): """ @@ -2928,15 +2929,15 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemStateTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_09_30.models.HyperVGeneration :keyword features: A list of gallery image features. :paramtype features: list[~azure.mgmt.compute.v2020_09_30.models.GalleryImageFeature] @@ -2991,8 +2992,8 @@ class GalleryImageVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2020_09_30.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2020_09_30.models.GalleryImageVersionPropertiesProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -3028,8 +3029,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["GalleryImageVersionStorageProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -3075,7 +3076,7 @@ class GalleryImageVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImageVersion"], + value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs ): @@ -3112,7 +3113,7 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_09_30.models.StorageAccountType """ @@ -3133,11 +3134,11 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, **kwargs ): """ @@ -3155,7 +3156,7 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_09_30.models.StorageAccountType @@ -3183,9 +3184,9 @@ class GalleryImageVersionStorageProfile(msrest.serialization.Model): def __init__( self, *, - source: Optional["GalleryArtifactVersionSource"] = None, - os_disk_image: Optional["GalleryOSDiskImage"] = None, - data_disk_images: Optional[List["GalleryDataDiskImage"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, + os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, + data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, **kwargs ): """ @@ -3218,8 +3219,8 @@ class GalleryImageVersionUpdate(UpdateResourceDefinition): :ivar publishing_profile: The publishing profile of a gallery image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2020_09_30.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2020_09_30.models.GalleryImageVersionPropertiesProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -3252,8 +3253,8 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["GalleryImageVersionStorageProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -3297,7 +3298,7 @@ class GalleryList(msrest.serialization.Model): def __init__( self, *, - value: List["Gallery"], + value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs ): @@ -3321,7 +3322,7 @@ class GalleryOSDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2020_09_30.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2020_09_30.models.GalleryArtifactVersionSource @@ -3340,13 +3341,13 @@ class GalleryOSDiskImage(GalleryDiskImage): def __init__( self, *, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2020_09_30.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2020_09_30.models.GalleryArtifactVersionSource @@ -3372,8 +3373,8 @@ class GalleryUpdate(UpdateResourceDefinition): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2020_09_30.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2020_09_30.models.GalleryPropertiesProvisioningState :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. @@ -3403,8 +3404,8 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, - sharing_profile: Optional["SharingProfile"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, + sharing_profile: Optional["_models.SharingProfile"] = None, **kwargs ): """ @@ -3430,7 +3431,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read", "Write". + :ivar access: Required. Known values are: "None", "Read", "Write". :vartype access: str or ~azure.mgmt.compute.v2020_09_30.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -3449,12 +3450,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read", "Write". + :keyword access: Required. Known values are: "None", "Read", "Write". :paramtype access: str or ~azure.mgmt.compute.v2020_09_30.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -3603,7 +3604,7 @@ def __init__( self, *, key_url: str, - source_vault: Optional["SourceVault"] = None, + source_vault: Optional["_models.SourceVault"] = None, **kwargs ): """ @@ -3643,7 +3644,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -3682,7 +3683,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -3869,7 +3870,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype private_link_service_connection_state: ~azure.mgmt.compute.v2020_09_30.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.compute.v2020_09_30.models.PrivateEndpointConnectionProvisioningState """ @@ -3893,8 +3894,8 @@ class PrivateEndpointConnection(msrest.serialization.Model): 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 ): """ @@ -3932,7 +3933,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -4017,7 +4018,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -4032,7 +4033,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.compute.v2020_09_30.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -4051,14 +4052,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, actions_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.compute.v2020_09_30.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -4146,8 +4147,8 @@ class RecommendedMachineConfiguration(msrest.serialization.Model): def __init__( self, *, - v_cp_us: Optional["ResourceRange"] = None, - memory: Optional["ResourceRange"] = None, + v_cp_us: Optional["_models.ResourceRange"] = None, + memory: Optional["_models.ResourceRange"] = None, **kwargs ): """ @@ -4168,7 +4169,7 @@ class RegionalReplicationStatus(msrest.serialization.Model): :ivar region: The region to which the gallery image version is being replicated to. :vartype region: str - :ivar state: This is the regional replication state. Possible values include: "Unknown", + :ivar state: This is the regional replication state. Known values are: "Unknown", "Replicating", "Completed", "Failed". :vartype state: str or ~azure.mgmt.compute.v2020_09_30.models.ReplicationState :ivar details: The details of the replication status. @@ -4210,8 +4211,7 @@ class ReplicationStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Possible values include: "Unknown", "InProgress", "Completed", - "Failed". + replication status flags. Known values are: "Unknown", "InProgress", "Completed", "Failed". :vartype aggregated_state: str or ~azure.mgmt.compute.v2020_09_30.models.AggregatedReplicationState :ivar summary: This is a summary of replication status for each region. @@ -4363,11 +4363,11 @@ class SharedGalleryImage(PirSharedGalleryResource): :vartype unique_id: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemStateTypes :ivar end_of_life_date: The end of life date of the gallery image definition. This property can @@ -4381,7 +4381,7 @@ class SharedGalleryImage(PirSharedGalleryResource): :ivar disallowed: Describes the disallowed disk types. :vartype disallowed: ~azure.mgmt.compute.v2020_09_30.models.Disallowed :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_09_30.models.HyperVGeneration :ivar features: A list of gallery image features. :vartype features: list[~azure.mgmt.compute.v2020_09_30.models.GalleryImageFeature] @@ -4414,15 +4414,15 @@ def __init__( self, *, unique_id: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - features: Optional[List["GalleryImageFeature"]] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, **kwargs ): """ @@ -4430,12 +4430,12 @@ def __init__( :paramtype unique_id: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemStateTypes :keyword end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -4448,7 +4448,7 @@ def __init__( :keyword disallowed: Describes the disallowed disk types. :paramtype disallowed: ~azure.mgmt.compute.v2020_09_30.models.Disallowed :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_09_30.models.HyperVGeneration :keyword features: A list of gallery image features. :paramtype features: list[~azure.mgmt.compute.v2020_09_30.models.GalleryImageFeature] @@ -4492,7 +4492,7 @@ class SharedGalleryImageList(msrest.serialization.Model): def __init__( self, *, - value: List["SharedGalleryImage"], + value: List["_models.SharedGalleryImage"], next_link: Optional[str] = None, **kwargs ): @@ -4587,7 +4587,7 @@ class SharedGalleryImageVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["SharedGalleryImageVersion"], + value: List["_models.SharedGalleryImageVersion"], next_link: Optional[str] = None, **kwargs ): @@ -4627,7 +4627,7 @@ class SharedGalleryList(msrest.serialization.Model): def __init__( self, *, - value: List["SharedGallery"], + value: List["_models.SharedGallery"], next_link: Optional[str] = None, **kwargs ): @@ -4677,7 +4677,7 @@ class SharingProfile(msrest.serialization.Model): :ivar permissions: This property allows you to specify the permission of sharing gallery. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Private** - :code:`
`:code:`
` **Groups**. Possible values include: "Private", "Groups". + :code:`
`:code:`
` **Groups**. Known values are: "Private", "Groups". :vartype permissions: str or ~azure.mgmt.compute.v2020_09_30.models.GallerySharingPermissionTypes :ivar groups: A list of sharing profile groups. @@ -4696,13 +4696,13 @@ class SharingProfile(msrest.serialization.Model): def __init__( self, *, - permissions: Optional[Union[str, "GallerySharingPermissionTypes"]] = None, + permissions: Optional[Union[str, "_models.GallerySharingPermissionTypes"]] = None, **kwargs ): """ :keyword permissions: This property allows you to specify the permission of sharing gallery. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Private** - :code:`
`:code:`
` **Groups**. Possible values include: "Private", "Groups". + :code:`
`:code:`
` **Groups**. Known values are: "Private", "Groups". :paramtype permissions: str or ~azure.mgmt.compute.v2020_09_30.models.GallerySharingPermissionTypes """ @@ -4716,8 +4716,7 @@ class SharingProfileGroup(msrest.serialization.Model): :ivar type: This property allows you to specify the type of sharing group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Subscriptions** - :code:`
`:code:`
` **AADTenants**. Possible values include: "Subscriptions", - "AADTenants". + :code:`
`:code:`
` **AADTenants**. Known values are: "Subscriptions", "AADTenants". :vartype type: str or ~azure.mgmt.compute.v2020_09_30.models.SharingProfileGroupTypes :ivar ids: A list of subscription/tenant ids the gallery is aimed to be shared to. :vartype ids: list[str] @@ -4731,15 +4730,14 @@ class SharingProfileGroup(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "SharingProfileGroupTypes"]] = None, + type: Optional[Union[str, "_models.SharingProfileGroupTypes"]] = None, ids: Optional[List[str]] = None, **kwargs ): """ :keyword type: This property allows you to specify the type of sharing group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Subscriptions** - :code:`
`:code:`
` **AADTenants**. Possible values include: "Subscriptions", - "AADTenants". + :code:`
`:code:`
` **AADTenants**. Known values are: "Subscriptions", "AADTenants". :paramtype type: str or ~azure.mgmt.compute.v2020_09_30.models.SharingProfileGroupTypes :keyword ids: A list of subscription/tenant ids the gallery is aimed to be shared to. :paramtype ids: list[str] @@ -4756,8 +4754,8 @@ class SharingUpdate(msrest.serialization.Model): :ivar operation_type: Required. This property allows you to specify the operation type of gallery sharing update. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` - **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Possible values - include: "Add", "Remove", "Reset". + **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Known values + are: "Add", "Remove", "Reset". :vartype operation_type: str or ~azure.mgmt.compute.v2020_09_30.models.SharingUpdateOperationTypes :ivar groups: A list of sharing profile groups. @@ -4776,15 +4774,15 @@ class SharingUpdate(msrest.serialization.Model): def __init__( self, *, - operation_type: Union[str, "SharingUpdateOperationTypes"], - groups: Optional[List["SharingProfileGroup"]] = None, + operation_type: Union[str, "_models.SharingUpdateOperationTypes"], + groups: Optional[List["_models.SharingProfileGroup"]] = None, **kwargs ): """ :keyword operation_type: Required. This property allows you to specify the operation type of gallery sharing update. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` - **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Possible values - include: "Add", "Remove", "Reset". + **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Known values + are: "Add", "Remove", "Reset". :paramtype operation_type: str or ~azure.mgmt.compute.v2020_09_30.models.SharingUpdateOperationTypes :keyword groups: A list of sharing profile groups. @@ -4823,10 +4821,10 @@ class Snapshot(Resource): :vartype extended_location: ~azure.mgmt.compute.v2020_09_30.models.ExtendedLocation :ivar time_created: The time when the snapshot was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_09_30.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. @@ -4841,7 +4839,7 @@ class Snapshot(Resource): :vartype disk_size_gb: int :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. :vartype disk_size_bytes: long - :ivar disk_state: The state of the snapshot. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the snapshot. Known values are: "Unattached", "Attached", "Reserved", "ActiveSAS", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2020_09_30.models.DiskState :ivar unique_id: Unique Guid identifying the resource. @@ -4858,8 +4856,8 @@ class Snapshot(Resource): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2020_09_30.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_09_30.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -4910,17 +4908,17 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - extended_location: Optional["ExtendedLocation"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, incremental: Optional[bool] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, **kwargs ): @@ -4936,10 +4934,10 @@ def __init__( :keyword extended_location: The extended location where the snapshot will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2020_09_30.models.ExtendedLocation - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_09_30.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. @@ -4962,8 +4960,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2020_09_30.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_09_30.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -5015,7 +5013,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -5036,8 +5034,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2020_09_30.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -5055,12 +5052,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2020_09_30.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -5077,7 +5073,7 @@ class SnapshotUpdate(msrest.serialization.Model): an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. :vartype sku: ~azure.mgmt.compute.v2020_09_30.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -5091,8 +5087,8 @@ class SnapshotUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2020_09_30.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_09_30.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -5114,12 +5110,12 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, **kwargs ): @@ -5130,7 +5126,7 @@ def __init__( is an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. :paramtype sku: ~azure.mgmt.compute.v2020_09_30.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_09_30.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -5144,8 +5140,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2020_09_30.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_09_30.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -5199,7 +5195,7 @@ class TargetRegion(msrest.serialization.Model): region. This property is updatable. :vartype regional_replica_count: int :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_09_30.models.StorageAccountType :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS @@ -5223,8 +5219,8 @@ def __init__( *, name: str, regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - encryption: Optional["EncryptionImages"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + encryption: Optional["_models.EncryptionImages"] = None, **kwargs ): """ @@ -5234,7 +5230,7 @@ def __init__( region. This property is updatable. :paramtype regional_replica_count: int :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_09_30.models.StorageAccountType diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/__init__.py index fa8761318cfa..2f4d2e8ca379 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/__init__.py @@ -21,6 +21,9 @@ from ._shared_gallery_images_operations import SharedGalleryImagesOperations from ._shared_gallery_image_versions_operations import SharedGalleryImageVersionsOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', @@ -37,3 +40,5 @@ 'SharedGalleryImagesOperations', 'SharedGalleryImageVersionsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disk_accesses_operations.py index 6c8f5c718f31..127e64312be0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccess] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccessUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_get_private_link_resources_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,18 +284,16 @@ def build_get_private_link_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -297,14 +304,17 @@ def build_update_a_private_endpoint_connection_request_initial( disk_access_name: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -317,20 +327,18 @@ def build_update_a_private_endpoint_connection_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -344,9 +352,12 @@ def build_get_a_private_endpoint_connection_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -359,18 +370,16 @@ def build_get_a_private_endpoint_connection_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -382,9 +391,12 @@ def build_delete_a_private_endpoint_connection_request_initial( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -397,18 +409,16 @@ def build_delete_a_private_endpoint_connection_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -419,9 +429,12 @@ def build_list_private_endpoint_connections_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections") # pylint: disable=line-too-long path_format_arguments = { @@ -433,58 +446,57 @@ def build_list_private_endpoint_connections_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskAccessesOperations(object): - """DiskAccessesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -496,11 +508,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,9 +544,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -555,37 +569,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -602,17 +626,20 @@ def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -624,11 +651,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -658,9 +687,9 @@ def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -683,37 +712,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -732,7 +771,7 @@ def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -746,13 +785,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -761,11 +803,13 @@ def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -792,13 +836,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -807,11 +854,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -855,20 +904,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -878,8 +932,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -897,7 +957,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -907,13 +967,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -922,9 +985,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -933,9 +998,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -972,7 +1039,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -980,13 +1047,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -994,9 +1064,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1004,9 +1076,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1045,7 +1119,7 @@ def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -1059,13 +1133,16 @@ def get_private_link_resources( :rtype: ~azure.mgmt.compute.v2020_09_30.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', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -1074,11 +1151,13 @@ def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1104,17 +1183,20 @@ def _update_a_private_endpoint_connection_initial( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: 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(private_endpoint_connection, 'PrivateEndpointConnection') @@ -1127,11 +1209,13 @@ def _update_a_private_endpoint_connection_initial( content_type=content_type, json=_json, template_url=self._update_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1162,9 +1246,9 @@ def begin_update_a_private_endpoint_connection( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection under disk access resource, this can't be used to create a new private endpoint connection. @@ -1194,17 +1278,20 @@ def begin_update_a_private_endpoint_connection( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: 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] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_a_private_endpoint_connection_initial( + raw_result = self._update_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -1212,20 +1299,27 @@ def begin_update_a_private_endpoint_connection( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -1245,7 +1339,7 @@ def get_a_private_endpoint_connection( disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about a private endpoint connection under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1261,13 +1355,16 @@ def get_a_private_endpoint_connection( :rtype: ~azure.mgmt.compute.v2020_09_30.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', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_a_private_endpoint_connection_request( @@ -1277,11 +1374,13 @@ def get_a_private_endpoint_connection( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get_a_private_endpoint_connection.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1309,13 +1408,16 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsiste private_endpoint_connection_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', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_a_private_endpoint_connection_request_initial( @@ -1325,11 +1427,13 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsiste private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1376,21 +1480,26 @@ def begin_delete_a_private_endpoint_connection( # pylint: disable=inconsistent- :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_a_private_endpoint_connection_initial( + raw_result = self._delete_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1400,8 +1509,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1420,7 +1535,7 @@ def list_private_endpoint_connections( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List information about private endpoint connections under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1436,13 +1551,16 @@ def list_private_endpoint_connections( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - 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: @@ -1452,9 +1570,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=self.list_private_endpoint_connections.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1464,9 +1584,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disk_encryption_sets_operations.py index e8a8ec693322..4eee70207a39 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_list_associated_resources_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,58 +284,57 @@ def build_list_associated_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskEncryptionSetsOperations(object): - """DiskEncryptionSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -338,11 +346,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -372,9 +382,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -399,37 +409,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -446,17 +466,20 @@ def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -468,11 +491,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,9 +527,9 @@ def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -529,37 +554,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -578,7 +613,7 @@ def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -592,13 +627,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -607,11 +645,13 @@ def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -638,13 +678,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -653,11 +696,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -701,20 +746,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -724,8 +774,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -743,7 +799,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -755,13 +811,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -770,9 +829,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -781,9 +842,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -820,7 +883,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -830,13 +893,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -844,9 +910,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -854,9 +922,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -895,7 +965,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> Iterable["_models.ResourceUriList"]: + ) -> Iterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -909,13 +979,16 @@ def list_associated_resources( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -925,9 +998,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -937,9 +1012,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disk_restore_point_operations.py index c21776d101d0..aaf6f5f67f69 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disk_restore_point_operations.py @@ -16,6 +16,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( disk_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -50,18 +54,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -73,9 +75,12 @@ def build_list_by_restore_point_request( vm_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints") # pylint: disable=line-too-long path_format_arguments = { @@ -88,42 +93,38 @@ def build_list_by_restore_point_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskRestorePointOperations(object): - """DiskRestorePointOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskRestorePointOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -133,7 +134,7 @@ def get( vm_restore_point_name: str, disk_restore_point_name: str, **kwargs: Any - ) -> "_models.DiskRestorePoint": + ) -> _models.DiskRestorePoint: """Get disk restorePoint resource. :param resource_group_name: The name of the resource group. @@ -154,13 +155,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.DiskRestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePoint] request = build_get_request( @@ -171,11 +175,13 @@ def get( disk_restore_point_name=disk_restore_point_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -203,7 +209,7 @@ def list_by_restore_point( restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> Iterable["_models.DiskRestorePointList"]: + ) -> Iterable[_models.DiskRestorePointList]: """Lists diskRestorePoints under a vmRestorePoint. :param resource_group_name: The name of the resource group. @@ -223,13 +229,16 @@ def list_by_restore_point( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskRestorePointList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePointList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePointList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -240,9 +249,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=self.list_by_restore_point.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -253,9 +264,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disks_operations.py index b5dce990dd00..f8581686257f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_galleries_operations.py index 3d71393103c9..b980ef01bddd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.Gallery] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -125,9 +127,12 @@ def build_get_request( select: Optional[Union[str, "_models.SelectPermissions"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -139,20 +144,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -163,9 +166,12 @@ def build_delete_request_initial( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,18 +183,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries") # pylint: disable=line-too-long path_format_arguments = { @@ -211,18 +218,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +236,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") path_format_arguments = { @@ -243,58 +251,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleriesOperations(object): - """GalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -306,11 +313,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -343,9 +352,9 @@ def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -367,37 +376,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -414,17 +433,20 @@ def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'GalleryUpdate') @@ -436,11 +458,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -466,9 +490,9 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -490,37 +514,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -540,7 +574,7 @@ def get( gallery_name: str, select: Optional[Union[str, "_models.SelectPermissions"]] = None, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -554,13 +588,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -570,11 +607,13 @@ def get( api_version=api_version, select=select, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -601,13 +640,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -616,11 +658,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -662,20 +706,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +734,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -704,7 +759,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -714,13 +769,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -729,9 +787,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -740,9 +800,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -779,7 +841,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -787,13 +849,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -801,9 +866,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -811,9 +878,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_application_versions_operations.py index 7498c07e0be0..3db09b61c0ee 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +137,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +156,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -177,9 +180,12 @@ def build_delete_request_initial( gallery_application_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +199,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -216,9 +220,12 @@ def build_list_by_gallery_application_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -231,42 +238,38 @@ def build_list_by_gallery_application_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationVersionsOperations(object): - """GalleryApplicationVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -274,17 +277,20 @@ def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -298,11 +304,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -373,17 +381,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -392,20 +403,27 @@ def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -424,17 +442,20 @@ def _update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersionUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,9 +503,9 @@ def begin_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -516,17 +539,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -535,20 +561,27 @@ def begin_update( 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('GalleryApplicationVersion', 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( @@ -570,7 +603,7 @@ def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -591,13 +624,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -609,11 +645,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -642,13 +680,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -659,11 +700,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -714,22 +757,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -739,8 +787,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -760,7 +814,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationVersionList"]: + ) -> Iterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -778,13 +832,16 @@ def list_by_gallery_application( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +852,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -808,9 +867,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_applications_operations.py index a515713becb6..30da58350543 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplication] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_get_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -181,18 +187,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +207,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications") # pylint: disable=line-too-long path_format_arguments = { @@ -217,59 +224,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationsOperations(object): - """GalleryApplicationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -282,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -320,9 +328,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -351,17 +359,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -369,20 +380,27 @@ def begin_create_or_update( 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('GalleryApplication', 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( @@ -400,17 +418,20 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplicationUpdate') @@ -423,11 +444,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -454,9 +477,9 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -484,17 +507,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -502,20 +528,27 @@ def begin_update( 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('GalleryApplication', 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( @@ -535,7 +568,7 @@ def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -551,13 +584,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -567,11 +603,13 @@ def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -599,13 +637,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -615,11 +656,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -665,21 +708,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -689,8 +737,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -709,7 +763,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationList"]: + ) -> Iterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -724,13 +778,16 @@ def list_by_gallery( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -740,9 +797,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -752,9 +811,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_image_versions_operations.py index aa217341678c..b32f9b0b8cb6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +137,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +156,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -177,9 +180,12 @@ def build_delete_request_initial( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +199,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -216,9 +220,12 @@ def build_list_by_gallery_image_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -231,42 +238,38 @@ def build_list_by_gallery_image_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImageVersionsOperations(object): - """GalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -274,17 +277,20 @@ def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -298,11 +304,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Create or update a gallery image version. :param resource_group_name: The name of the resource group. @@ -372,17 +380,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -423,17 +441,20 @@ def _update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersionUpdate') @@ -447,11 +468,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -479,9 +502,9 @@ def begin_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Update a gallery image version. :param resource_group_name: The name of the resource group. @@ -514,17 +537,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -533,20 +559,27 @@ def begin_update( 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('GalleryImageVersion', 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( @@ -568,7 +601,7 @@ def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery image version. :param resource_group_name: The name of the resource group. @@ -588,13 +621,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -606,11 +642,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -639,13 +677,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -656,11 +697,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -710,22 +753,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -735,8 +783,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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,7 +810,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageVersionList"]: + ) -> Iterable[_models.GalleryImageVersionList]: """List gallery image versions in a gallery image definition. :param resource_group_name: The name of the resource group. @@ -774,13 +828,16 @@ def list_by_gallery_image( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -791,9 +848,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -804,9 +863,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_images_operations.py index 51ee8a139bda..4e19a3855c38 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImage] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -181,18 +187,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +207,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images") # pylint: disable=line-too-long path_format_arguments = { @@ -217,59 +224,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImagesOperations(object): - """GalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -282,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -320,9 +328,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Create or update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -349,17 +357,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -367,20 +378,27 @@ def begin_create_or_update( 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('GalleryImage', 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( @@ -398,17 +416,20 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImageUpdate') @@ -421,11 +442,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +475,9 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -481,17 +504,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -499,20 +525,27 @@ def begin_update( 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('GalleryImage', 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( @@ -532,7 +565,7 @@ def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery image definition. :param resource_group_name: The name of the resource group. @@ -547,13 +580,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -563,11 +599,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,13 +633,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -611,11 +652,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -661,21 +704,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +733,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +759,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageList"]: + ) -> Iterable[_models.GalleryImageList]: """List gallery image definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -718,13 +772,16 @@ def list_by_gallery( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -734,9 +791,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -746,9 +805,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_sharing_profile_operations.py index 2127d5c3e62b..5c1ce4b64197 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_sharing_profile_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_gallery_sharing_profile_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +33,17 @@ def build_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.SharingUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share") # pylint: disable=line-too-long path_format_arguments = { @@ -52,62 +55,61 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class GallerySharingProfileOperations(object): - """GallerySharingProfileOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GallerySharingProfileOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`gallery_sharing_profile` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _update_initial( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> "_models.SharingUpdate": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] + ) -> _models.SharingUpdate: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharingUpdate] _json = self._serialize.body(sharing_update, 'SharingUpdate') @@ -119,11 +121,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -153,9 +157,9 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> LROPoller["_models.SharingUpdate"]: + ) -> LROPoller[_models.SharingUpdate]: """Update sharing profile of a gallery. :param resource_group_name: The name of the resource group. @@ -177,37 +181,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.SharingUpdate] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharingUpdate] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, sharing_update=sharing_update, 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('SharingUpdate', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_shared_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_shared_galleries_operations.py index ace50147728f..6a30e19a79ca 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_shared_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_shared_galleries_operations.py @@ -16,6 +16,7 @@ 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 @@ -33,9 +34,12 @@ def build_list_request( shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries") # pylint: disable=line-too-long path_format_arguments = { @@ -46,20 +50,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 shared_to is not None: - _query_parameters['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') + _params['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -70,9 +72,12 @@ def build_get_request( gallery_unique_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}") # pylint: disable=line-too-long path_format_arguments = { @@ -84,42 +89,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class SharedGalleriesOperations(object): - """SharedGalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharedGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`shared_galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -127,7 +128,7 @@ def list( location: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> Iterable["_models.SharedGalleryList"]: + ) -> Iterable[_models.SharedGalleryList]: """List shared galleries by subscription id or tenant id. :param location: Resource location. @@ -140,13 +141,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.SharedGalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -156,9 +160,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -168,9 +174,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -209,7 +217,7 @@ def get( location: str, gallery_unique_name: str, **kwargs: Any - ) -> "_models.SharedGallery": + ) -> _models.SharedGallery: """Get a shared gallery by subscription id or tenant id. :param location: Resource location. @@ -221,13 +229,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.SharedGallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGallery] request = build_get_request( @@ -236,11 +247,13 @@ def get( gallery_unique_name=gallery_unique_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_shared_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_shared_gallery_image_versions_operations.py index 068485d1d315..418e839156e8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_shared_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_shared_gallery_image_versions_operations.py @@ -16,6 +16,7 @@ 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 @@ -35,9 +36,12 @@ def build_list_request( shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +54,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 shared_to is not None: - _query_parameters['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') + _params['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -76,9 +78,12 @@ def build_get_request( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -92,42 +97,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class SharedGalleryImageVersionsOperations(object): - """SharedGalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharedGalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`shared_gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -137,7 +138,7 @@ def list( gallery_image_name: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> Iterable["_models.SharedGalleryImageVersionList"]: + ) -> Iterable[_models.SharedGalleryImageVersionList]: """List shared gallery image versions by subscription id or tenant id. :param location: Resource location. @@ -157,13 +158,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.SharedGalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -175,9 +179,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -189,9 +195,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -232,7 +240,7 @@ def get( gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any - ) -> "_models.SharedGalleryImageVersion": + ) -> _models.SharedGalleryImageVersion: """Get a shared gallery image version by subscription id or tenant id. :param location: Resource location. @@ -252,13 +260,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.SharedGalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageVersion] request = build_get_request( @@ -269,11 +280,13 @@ def get( gallery_image_version_name=gallery_image_version_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_shared_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_shared_gallery_images_operations.py index 65ee9671afb0..99e4ef4b0cf7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_shared_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_shared_gallery_images_operations.py @@ -16,6 +16,7 @@ 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 @@ -34,9 +35,12 @@ def build_list_request( shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images") # pylint: disable=line-too-long path_format_arguments = { @@ -48,20 +52,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 shared_to is not None: - _query_parameters['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') + _params['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -73,9 +75,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -88,42 +93,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class SharedGalleryImagesOperations(object): - """SharedGalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharedGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`shared_gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -132,7 +133,7 @@ def list( gallery_unique_name: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> Iterable["_models.SharedGalleryImageList"]: + ) -> Iterable[_models.SharedGalleryImageList]: """List shared gallery images by subscription id or tenant id. :param location: Resource location. @@ -149,13 +150,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.SharedGalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -166,9 +170,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -179,9 +185,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -221,7 +229,7 @@ def get( gallery_unique_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.SharedGalleryImage": + ) -> _models.SharedGalleryImage: """Get a shared gallery image by subscription id or tenant id. :param location: Resource location. @@ -236,13 +244,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.SharedGalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImage] request = build_get_request( @@ -252,11 +263,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_snapshots_operations.py index 7a71cf12e486..1d0d7505d950 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_09_30/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = case_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-09-30")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_09_30.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2020_09_30.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_09_30.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_09_30.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_09_30.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-09-30")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2020-09-30") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-09-30")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-09-30") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-09-30")) # 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/_compute_management_client.py index a4050ab247d6..0e936337bbe6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/_compute_management_client.py @@ -65,10 +65,18 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.cloud_service_role_instances = CloudServiceRoleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_service_roles = CloudServiceRolesOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_services = CloudServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_services_update_domain = CloudServicesUpdateDomainOperations(self._client, self._config, self._serialize, self._deserialize) + self.cloud_service_role_instances = CloudServiceRoleInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_roles = CloudServiceRolesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services = CloudServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services_update_domain = CloudServicesUpdateDomainOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/_compute_management_client.py index 2bc54d56d9c5..411e630428be 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/_compute_management_client.py @@ -65,10 +65,18 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.cloud_service_role_instances = CloudServiceRoleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_service_roles = CloudServiceRolesOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_services = CloudServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_services_update_domain = CloudServicesUpdateDomainOperations(self._client, self._config, self._serialize, self._deserialize) + self.cloud_service_role_instances = CloudServiceRoleInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_roles = CloudServiceRolesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services = CloudServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services_update_domain = CloudServicesUpdateDomainOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/__init__.py index 0ecb0abd1ee4..38708e65a4a7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/__init__.py @@ -11,9 +11,14 @@ from ._cloud_services_operations import CloudServicesOperations from ._cloud_services_update_domain_operations import CloudServicesUpdateDomainOperations +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__ = [ 'CloudServiceRoleInstancesOperations', 'CloudServiceRolesOperations', 'CloudServicesOperations', 'CloudServicesUpdateDomainOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_service_role_instances_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_service_role_instances_operations.py index 768094719346..3ed6b8df4bf6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_service_role_instances_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_service_role_instances_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CloudServiceRoleInstancesOperations: - """CloudServiceRoleInstancesOperations async operations. - - You 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.compute.v2020_10_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.compute.v2020_10_01_preview.aio.ComputeManagementClient`'s + :attr:`cloud_service_role_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -54,13 +53,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements cloud_service_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', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -70,11 +72,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,21 +123,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -143,8 +152,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -165,7 +180,7 @@ async def get( cloud_service_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.RoleInstance": + ) -> _models.RoleInstance: """Gets a role instance from a cloud service. :param role_instance_name: Name of the role instance. @@ -174,21 +189,24 @@ async def get( :type resource_group_name: str :param cloud_service_name: :type cloud_service_name: str - :param expand: The expand expression to apply to the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply to the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleInstance, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_10_01_preview.models.RoleInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstance] request = build_get_request( @@ -199,11 +217,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -231,7 +251,7 @@ async def get_instance_view( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.RoleInstanceView": + ) -> _models.RoleInstanceView: """Retrieves information about the run-time state of a role instance in a cloud service. :param role_instance_name: Name of the role instance. @@ -245,13 +265,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2020_10_01_preview.models.RoleInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstanceView] request = build_get_instance_view_request( @@ -261,11 +284,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -293,7 +318,7 @@ def list( cloud_service_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> AsyncIterable["_models.RoleInstanceListResult"]: + ) -> AsyncIterable[_models.RoleInstanceListResult]: """Gets the list of all role instances in a cloud service. Use nextLink property in the response to get the next page of role instances. Do this till nextLink is null to fetch all the role instances. @@ -302,8 +327,8 @@ def list( :type resource_group_name: str :param cloud_service_name: :type cloud_service_name: str - :param expand: The expand expression to apply to the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply to the operation. Known values are "instanceView" + or None. Default value is "instanceView". :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 RoleInstanceListResult or the result of @@ -312,13 +337,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_10_01_preview.models.RoleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstanceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -329,9 +357,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -342,9 +372,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -384,13 +416,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements cloud_service_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', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -400,11 +435,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,21 +487,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -474,8 +516,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -495,13 +543,16 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements cloud_service_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', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_request_initial( @@ -511,11 +562,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -561,21 +614,26 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -585,8 +643,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -606,13 +670,16 @@ async def _rebuild_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_rebuild_request_initial( @@ -622,11 +689,13 @@ async def _rebuild_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._rebuild_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -673,21 +742,26 @@ async def begin_rebuild( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._rebuild_initial( + raw_result = await self._rebuild_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -697,8 +771,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -732,13 +812,16 @@ async def get_remote_desktop_file( :rtype: IO :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[IO] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[IO] request = build_get_remote_desktop_file_request( @@ -748,11 +831,13 @@ async def get_remote_desktop_file( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_remote_desktop_file.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=True, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_service_roles_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_service_roles_operations.py index 15aaa62414dc..80bed65e09f2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_service_roles_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_service_roles_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CloudServiceRolesOperations: - """CloudServiceRolesOperations async operations. - - You 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.compute.v2020_10_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.compute.v2020_10_01_preview.aio.ComputeManagementClient`'s + :attr:`cloud_service_roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.CloudServiceRole": + ) -> _models.CloudServiceRole: """Gets a role from a cloud service. :param role_name: Name of the role. @@ -66,13 +65,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_10_01_preview.models.CloudServiceRole :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceRole"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceRole] request = build_get_request( @@ -82,11 +84,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,7 +117,7 @@ def list( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CloudServiceRoleListResult"]: + ) -> AsyncIterable[_models.CloudServiceRoleListResult]: """Gets a list of all roles in a cloud service. Use nextLink property in the response to get the next page of roles. Do this till nextLink is null to fetch all the roles. @@ -128,13 +132,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_10_01_preview.models.CloudServiceRoleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceRoleListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceRoleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -144,9 +151,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -156,9 +165,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_services_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_services_operations.py index 31076fb246f2..7f30d0f09e9c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_services_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_services_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CloudServicesOperations: # pylint: disable=too-many-public-methods - """CloudServicesOperations async operations. - - You 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.compute.v2020_10_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.compute.v2020_10_01_preview.aio.ComputeManagementClient`'s + :attr:`cloud_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") + async def _create_or_update_initial( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudService"] = None, + parameters: Optional[_models.CloudService] = None, **kwargs: Any - ) -> "_models.CloudService": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] + ) -> _models.CloudService: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] if parameters is not None: _json = self._serialize.body(parameters, 'CloudService') @@ -76,11 +78,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudService"] = None, + parameters: Optional[_models.CloudService] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.CloudService"]: + ) -> AsyncLROPoller[_models.CloudService]: """Create or update a cloud service. Please note some properties can be set only during cloud service creation. @@ -136,37 +140,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_10_01_preview.models.CloudService] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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('CloudService', 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( @@ -183,17 +197,20 @@ async def _update_initial( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudServiceUpdate"] = None, + parameters: Optional[_models.CloudServiceUpdate] = None, **kwargs: Any - ) -> "_models.CloudService": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] + ) -> _models.CloudService: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] if parameters is not None: _json = self._serialize.body(parameters, 'CloudServiceUpdate') @@ -208,11 +225,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -238,9 +257,9 @@ async def begin_update( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudServiceUpdate"] = None, + parameters: Optional[_models.CloudServiceUpdate] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.CloudService"]: + ) -> AsyncLROPoller[_models.CloudService]: """Update a cloud service. :param resource_group_name: Name of the resource group. @@ -263,37 +282,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_10_01_preview.models.CloudService] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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('CloudService', 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( @@ -312,13 +341,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -327,11 +359,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -373,20 +407,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -396,8 +435,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -416,7 +461,7 @@ async def get( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.CloudService": + ) -> _models.CloudService: """Display information about a cloud service. :param resource_group_name: Name of the resource group. @@ -428,13 +473,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_10_01_preview.models.CloudService :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] request = build_get_request( @@ -443,11 +491,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -474,7 +524,7 @@ async def get_instance_view( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.CloudServiceInstanceView": + ) -> _models.CloudServiceInstanceView: """Gets the status of a cloud service. :param resource_group_name: Name of the resource group. @@ -486,13 +536,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2020_10_01_preview.models.CloudServiceInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceInstanceView] request = build_get_instance_view_request( @@ -501,11 +554,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,7 +585,7 @@ async def get_instance_view( def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.CloudServiceListResult"]: + ) -> AsyncIterable[_models.CloudServiceListResult]: """Gets a list of all cloud services in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud Services. @@ -542,13 +597,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_10_01_preview.models.CloudServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -556,9 +614,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_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,9 +626,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -606,7 +668,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CloudServiceListResult"]: + ) -> AsyncIterable[_models.CloudServiceListResult]: """Gets a list of all cloud services under a resource group. Use nextLink property in the response to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud Services. @@ -620,13 +682,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_10_01_preview.models.CloudServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -635,9 +700,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -646,9 +713,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -687,13 +756,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -702,11 +774,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -748,20 +822,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -771,8 +850,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -791,13 +876,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -806,11 +894,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -853,20 +943,25 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -876,8 +971,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -894,17 +995,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -919,11 +1023,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -945,7 +1051,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more role instances in a cloud service. @@ -968,23 +1074,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-10-01-preview")) # 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] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -994,8 +1105,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1012,17 +1129,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1037,11 +1157,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1063,7 +1185,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimage asynchronous operation reinstalls the operating system on instances of web roles or @@ -1087,23 +1209,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-10-01-preview")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1113,8 +1240,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1131,17 +1264,20 @@ async def _rebuild_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1156,11 +1292,13 @@ async def _rebuild_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._rebuild_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1182,7 +1320,7 @@ async def begin_rebuild( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker @@ -1207,23 +1345,28 @@ async def begin_rebuild( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-10-01-preview")) # 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] + 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._rebuild_initial( + raw_result = await self._rebuild_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1233,8 +1376,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1251,17 +1400,20 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1276,11 +1428,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1302,7 +1456,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes role instances in a cloud service. @@ -1325,23 +1479,28 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-10-01-preview")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1351,8 +1510,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_services_update_domain_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_services_update_domain_operations.py index 44c2d0eb2f2d..d3d832abf0cb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_services_update_domain_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_cloud_services_update_domain_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CloudServicesUpdateDomainOperations: - """CloudServicesUpdateDomainOperations async operations. - - You 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.compute.v2020_10_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.compute.v2020_10_01_preview.aio.ComputeManagementClient`'s + :attr:`cloud_services_update_domain` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _walk_update_domain_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, update_domain: int, - parameters: Optional["_models.UpdateDomain"] = None, + parameters: Optional[_models.UpdateDomain] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'UpdateDomain') @@ -78,11 +80,13 @@ async def _walk_update_domain_initial( # pylint: disable=inconsistent-return-st content_type=content_type, json=_json, template_url=self._walk_update_domain_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_walk_update_domain( # pylint: disable=inconsistent-return-state resource_group_name: str, cloud_service_name: str, update_domain: int, - parameters: Optional["_models.UpdateDomain"] = None, + parameters: Optional[_models.UpdateDomain] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Updates the role instances in the specified update domain. @@ -132,17 +136,20 @@ async def begin_walk_update_domain( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-10-01-preview")) # 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] + 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._walk_update_domain_initial( + raw_result = await self._walk_update_domain_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, update_domain=update_domain, @@ -150,6 +157,8 @@ async def begin_walk_update_domain( # pylint: disable=inconsistent-return-state api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,7 +195,7 @@ async def get_update_domain( cloud_service_name: str, update_domain: int, **kwargs: Any - ) -> "_models.UpdateDomain": + ) -> _models.UpdateDomain: """Gets the specified update domain of a cloud service. Use nextLink property in the response to get the next page of update domains. Do this till nextLink is null to fetch all the update domains. @@ -198,13 +213,16 @@ async def get_update_domain( :rtype: ~azure.mgmt.compute.v2020_10_01_preview.models.UpdateDomain :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateDomain"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateDomain] request = build_get_update_domain_request( @@ -214,11 +232,13 @@ async def get_update_domain( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_update_domain.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -245,7 +265,7 @@ def list_update_domains( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.UpdateDomainListResult"]: + ) -> AsyncIterable[_models.UpdateDomainListResult]: """Gets a list of all update domains in a cloud service. :param resource_group_name: Name of the resource group. @@ -259,13 +279,16 @@ def list_update_domains( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_10_01_preview.models.UpdateDomainListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateDomainListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateDomainListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -275,9 +298,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_update_domains.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -287,9 +312,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/__init__.py index 15828acce37a..abc09da032be 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/__init__.py @@ -51,7 +51,9 @@ CloudServiceUpgradeMode, StatusLevelTypes, ) - +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__ = [ 'ApiError', 'ApiErrorBase', @@ -95,3 +97,5 @@ 'CloudServiceUpgradeMode', 'StatusLevelTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/_compute_management_client_enums.py index 701bbbd8b437..17c243cd3843 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class CloudServiceUpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CloudServiceUpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Update mode for the cloud service. Role instances are allocated to update domains when the service is deployed. Updates can be initiated manually in each update domain or initiated automatically in all update domains. @@ -26,7 +25,7 @@ class CloudServiceUpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) MANUAL = "Manual" SIMULTANEOUS = "Simultaneous" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/_models_py3.py index 8d38419de26a..470c7f65b9a6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ApiError(msrest.serialization.Model): @@ -39,8 +41,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, @@ -147,7 +149,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - properties: Optional["CloudServiceProperties"] = None, + properties: Optional["_models.CloudServiceProperties"] = None, **kwargs ): """ @@ -181,7 +183,7 @@ class CloudServiceExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["Extension"]] = None, + extensions: Optional[List["_models.Extension"]] = None, **kwargs ): """ @@ -264,7 +266,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[str] = None, protected_settings: Optional[str] = None, - protected_settings_from_key_vault: Optional["CloudServiceVaultAndSecretReference"] = None, + protected_settings_from_key_vault: Optional["_models.CloudServiceVaultAndSecretReference"] = None, force_update_tag: Optional[str] = None, roles_applied_to: Optional[List[str]] = None, **kwargs @@ -351,7 +353,7 @@ class CloudServiceInstanceView(msrest.serialization.Model): def __init__( self, *, - role_instance: Optional["InstanceViewStatusesSummary"] = None, + role_instance: Optional["_models.InstanceViewStatusesSummary"] = None, **kwargs ): """ @@ -388,7 +390,7 @@ class CloudServiceListResult(msrest.serialization.Model): def __init__( self, *, - value: List["CloudService"], + value: List["_models.CloudService"], next_link: Optional[str] = None, **kwargs ): @@ -422,8 +424,8 @@ class CloudServiceNetworkProfile(msrest.serialization.Model): def __init__( self, *, - load_balancer_configurations: Optional[List["LoadBalancerConfiguration"]] = None, - swappable_cloud_service: Optional["SubResource"] = None, + load_balancer_configurations: Optional[List["_models.LoadBalancerConfiguration"]] = None, + swappable_cloud_service: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -454,7 +456,7 @@ class CloudServiceOsProfile(msrest.serialization.Model): def __init__( self, *, - secrets: Optional[List["CloudServiceVaultSecretGroup"]] = None, + secrets: Optional[List["_models.CloudServiceVaultSecretGroup"]] = None, **kwargs ): """ @@ -497,7 +499,7 @@ class CloudServiceProperties(msrest.serialization.Model): **Manual** :code:`
`:code:`
`\ **Simultaneous**\ :code:`
`:code:`
` If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called to apply the update. If set to Auto, the update is automatically applied to each update domain - in sequence. Possible values include: "Auto", "Manual", "Simultaneous". + in sequence. Known values are: "Auto", "Manual", "Simultaneous". :vartype upgrade_mode: str or ~azure.mgmt.compute.v2020_10_01_preview.models.CloudServiceUpgradeMode :ivar role_profile: Describes the role profile for the cloud service. @@ -542,11 +544,11 @@ def __init__( configuration: Optional[str] = None, configuration_url: Optional[str] = None, start_cloud_service: Optional[bool] = None, - upgrade_mode: Optional[Union[str, "CloudServiceUpgradeMode"]] = None, - role_profile: Optional["CloudServiceRoleProfile"] = None, - os_profile: Optional["CloudServiceOsProfile"] = None, - network_profile: Optional["CloudServiceNetworkProfile"] = None, - extension_profile: Optional["CloudServiceExtensionProfile"] = None, + upgrade_mode: Optional[Union[str, "_models.CloudServiceUpgradeMode"]] = None, + role_profile: Optional["_models.CloudServiceRoleProfile"] = None, + os_profile: Optional["_models.CloudServiceOsProfile"] = None, + network_profile: Optional["_models.CloudServiceNetworkProfile"] = None, + extension_profile: Optional["_models.CloudServiceExtensionProfile"] = None, **kwargs ): """ @@ -575,7 +577,7 @@ def __init__( **Manual** :code:`
`:code:`
`\ **Simultaneous**\ :code:`
`:code:`
` If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called to apply the update. If set to Auto, the update is automatically applied to each update domain - in sequence. Possible values include: "Auto", "Manual", "Simultaneous". + in sequence. Known values are: "Auto", "Manual", "Simultaneous". :paramtype upgrade_mode: str or ~azure.mgmt.compute.v2020_10_01_preview.models.CloudServiceUpgradeMode :keyword role_profile: Describes the role profile for the cloud service. @@ -641,8 +643,8 @@ class CloudServiceRole(msrest.serialization.Model): def __init__( self, *, - sku: Optional["CloudServiceRoleSku"] = None, - properties: Optional["CloudServiceRoleProperties"] = None, + sku: Optional["_models.CloudServiceRoleSku"] = None, + properties: Optional["_models.CloudServiceRoleProperties"] = None, **kwargs ): """ @@ -684,7 +686,7 @@ class CloudServiceRoleListResult(msrest.serialization.Model): def __init__( self, *, - value: List["CloudServiceRole"], + value: List["_models.CloudServiceRole"], next_link: Optional[str] = None, **kwargs ): @@ -714,7 +716,7 @@ class CloudServiceRoleProfile(msrest.serialization.Model): def __init__( self, *, - roles: Optional[List["CloudServiceRoleProfileProperties"]] = None, + roles: Optional[List["_models.CloudServiceRoleProfileProperties"]] = None, **kwargs ): """ @@ -744,7 +746,7 @@ def __init__( self, *, name: Optional[str] = None, - sku: Optional["CloudServiceRoleSku"] = None, + sku: Optional["_models.CloudServiceRoleSku"] = None, **kwargs ): """ @@ -872,7 +874,7 @@ class CloudServiceVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, + source_vault: Optional["_models.SubResource"] = None, secret_url: Optional[str] = None, **kwargs ): @@ -934,8 +936,8 @@ class CloudServiceVaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["CloudServiceVaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.CloudServiceVaultCertificate"]] = None, **kwargs ): """ @@ -971,7 +973,7 @@ def __init__( self, *, name: Optional[str] = None, - properties: Optional["CloudServiceExtensionProperties"] = None, + properties: Optional["_models.CloudServiceExtensionProperties"] = None, **kwargs ): """ @@ -1096,7 +1098,7 @@ def __init__( self, *, name: Optional[str] = None, - properties: Optional["LoadBalancerConfigurationProperties"] = None, + properties: Optional["_models.LoadBalancerConfigurationProperties"] = None, **kwargs ): """ @@ -1126,7 +1128,7 @@ class LoadBalancerConfigurationProperties(msrest.serialization.Model): def __init__( self, *, - frontend_ip_configurations: Optional[List["LoadBalancerFrontendIPConfiguration"]] = None, + frontend_ip_configurations: Optional[List["_models.LoadBalancerFrontendIPConfiguration"]] = None, **kwargs ): """ @@ -1157,7 +1159,7 @@ def __init__( self, *, name: Optional[str] = None, - properties: Optional["LoadBalancerFrontendIPConfigurationProperties"] = None, + properties: Optional["_models.LoadBalancerFrontendIPConfigurationProperties"] = None, **kwargs ): """ @@ -1192,8 +1194,8 @@ class LoadBalancerFrontendIPConfigurationProperties(msrest.serialization.Model): def __init__( self, *, - public_ip_address: Optional["SubResource"] = None, - subnet: Optional["SubResource"] = None, + public_ip_address: Optional["_models.SubResource"] = None, + subnet: Optional["_models.SubResource"] = None, private_ip_address: Optional[str] = None, **kwargs ): @@ -1224,7 +1226,7 @@ class ResourceInstanceViewStatus(msrest.serialization.Model): :vartype message: str :ivar time: The time of the status. :vartype time: ~datetime.datetime - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2020_10_01_preview.models.StatusLevelTypes """ @@ -1246,11 +1248,11 @@ class ResourceInstanceViewStatus(msrest.serialization.Model): def __init__( self, *, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, **kwargs ): """ - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2020_10_01_preview.models.StatusLevelTypes """ super(ResourceInstanceViewStatus, self).__init__(**kwargs) @@ -1303,8 +1305,8 @@ class RoleInstance(msrest.serialization.Model): def __init__( self, *, - sku: Optional["InstanceSku"] = None, - properties: Optional["RoleInstanceProperties"] = None, + sku: Optional["_models.InstanceSku"] = None, + properties: Optional["_models.RoleInstanceProperties"] = None, **kwargs ): """ @@ -1346,7 +1348,7 @@ class RoleInstanceListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RoleInstance"], + value: List["_models.RoleInstance"], next_link: Optional[str] = None, **kwargs ): @@ -1407,8 +1409,8 @@ class RoleInstanceProperties(msrest.serialization.Model): def __init__( self, *, - network_profile: Optional["RoleInstanceNetworkProfile"] = None, - instance_view: Optional["RoleInstanceView"] = None, + network_profile: Optional["_models.RoleInstanceNetworkProfile"] = None, + instance_view: Optional["_models.RoleInstanceView"] = None, **kwargs ): """ @@ -1613,7 +1615,7 @@ class UpdateDomainListResult(msrest.serialization.Model): def __init__( self, *, - value: List["UpdateDomain"], + value: List["_models.UpdateDomain"], next_link: Optional[str] = None, **kwargs ): diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/__init__.py index 0ecb0abd1ee4..38708e65a4a7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/__init__.py @@ -11,9 +11,14 @@ from ._cloud_services_operations import CloudServicesOperations from ._cloud_services_update_domain_operations import CloudServicesUpdateDomainOperations +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__ = [ 'CloudServiceRoleInstancesOperations', 'CloudServiceRolesOperations', 'CloudServicesOperations', 'CloudServicesUpdateDomainOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_service_role_instances_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_service_role_instances_operations.py index e9755b2a06c5..9afad903ea66 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_service_role_instances_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_service_role_instances_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,6 +17,7 @@ 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 @@ -35,9 +36,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -50,18 +54,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -75,9 +77,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -90,20 +95,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -115,9 +118,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -130,18 +136,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -154,9 +158,12 @@ def build_list_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances") # pylint: disable=line-too-long path_format_arguments = { @@ -168,20 +175,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -193,9 +198,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -208,18 +216,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +237,12 @@ def build_reimage_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -246,18 +255,16 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -269,9 +276,12 @@ def build_rebuild_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/rebuild") # pylint: disable=line-too-long path_format_arguments = { @@ -284,18 +294,16 @@ def build_rebuild_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -307,9 +315,12 @@ def build_get_remote_desktop_file_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/x-rdp") - accept = "application/x-rdp" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/remoteDesktopFile") # pylint: disable=line-too-long path_format_arguments = { @@ -322,42 +333,38 @@ def build_get_remote_desktop_file_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CloudServiceRoleInstancesOperations(object): - """CloudServiceRoleInstancesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CloudServiceRoleInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_10_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.compute.v2020_10_01_preview.ComputeManagementClient`'s + :attr:`cloud_service_role_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -366,13 +373,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements cloud_service_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', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -382,11 +392,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -431,21 +443,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +472,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -477,7 +500,7 @@ def get( cloud_service_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.RoleInstance": + ) -> _models.RoleInstance: """Gets a role instance from a cloud service. :param role_instance_name: Name of the role instance. @@ -486,21 +509,24 @@ def get( :type resource_group_name: str :param cloud_service_name: :type cloud_service_name: str - :param expand: The expand expression to apply to the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply to the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleInstance, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_10_01_preview.models.RoleInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstance] request = build_get_request( @@ -511,11 +537,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -543,7 +571,7 @@ def get_instance_view( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.RoleInstanceView": + ) -> _models.RoleInstanceView: """Retrieves information about the run-time state of a role instance in a cloud service. :param role_instance_name: Name of the role instance. @@ -557,13 +585,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2020_10_01_preview.models.RoleInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstanceView] request = build_get_instance_view_request( @@ -573,11 +604,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -605,7 +638,7 @@ def list( cloud_service_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> Iterable["_models.RoleInstanceListResult"]: + ) -> Iterable[_models.RoleInstanceListResult]: """Gets the list of all role instances in a cloud service. Use nextLink property in the response to get the next page of role instances. Do this till nextLink is null to fetch all the role instances. @@ -614,8 +647,8 @@ def list( :type resource_group_name: str :param cloud_service_name: :type cloud_service_name: str - :param expand: The expand expression to apply to the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply to the operation. Known values are "instanceView" + or None. Default value is "instanceView". :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 RoleInstanceListResult or the result of @@ -624,13 +657,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_10_01_preview.models.RoleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstanceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -641,9 +677,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -654,9 +692,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -696,13 +736,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -712,11 +755,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -762,21 +807,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._restart_initial( + raw_result = self._restart_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -786,8 +836,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -807,13 +863,16 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_request_initial( @@ -823,11 +882,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -873,21 +934,26 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -897,8 +963,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -918,13 +990,16 @@ def _rebuild_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_rebuild_request_initial( @@ -934,11 +1009,13 @@ def _rebuild_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._rebuild_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -985,21 +1062,26 @@ def begin_rebuild( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._rebuild_initial( + raw_result = self._rebuild_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1009,8 +1091,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1044,13 +1132,16 @@ def get_remote_desktop_file( :rtype: IO :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[IO] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[IO] request = build_get_remote_desktop_file_request( @@ -1060,11 +1151,13 @@ def get_remote_desktop_file( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_remote_desktop_file.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=True, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_service_roles_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_service_roles_operations.py index 6293b03a3a9b..67aebebb619d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_service_roles_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_service_roles_operations.py @@ -16,6 +16,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles/{roleName}") # pylint: disable=line-too-long path_format_arguments = { @@ -48,18 +52,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -70,9 +72,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles") # pylint: disable=line-too-long path_format_arguments = { @@ -84,42 +89,38 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CloudServiceRolesOperations(object): - """CloudServiceRolesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CloudServiceRolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_10_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.compute.v2020_10_01_preview.ComputeManagementClient`'s + :attr:`cloud_service_roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -128,7 +129,7 @@ def get( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.CloudServiceRole": + ) -> _models.CloudServiceRole: """Gets a role from a cloud service. :param role_name: Name of the role. @@ -142,13 +143,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_10_01_preview.models.CloudServiceRole :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceRole"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceRole] request = build_get_request( @@ -158,11 +162,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -189,7 +195,7 @@ def list( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> Iterable["_models.CloudServiceRoleListResult"]: + ) -> Iterable[_models.CloudServiceRoleListResult]: """Gets a list of all roles in a cloud service. Use nextLink property in the response to get the next page of roles. Do this till nextLink is null to fetch all the roles. @@ -204,13 +210,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_10_01_preview.models.CloudServiceRoleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceRoleListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceRoleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -220,9 +229,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -232,9 +243,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_services_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_services_operations.py index 031b041b4329..b61284b253a6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_services_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_services_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( cloud_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CloudService] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( cloud_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CloudServiceUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -195,9 +199,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -209,18 +216,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -229,9 +234,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/cloudServices") path_format_arguments = { @@ -241,18 +249,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -262,9 +268,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices") # pylint: disable=line-too-long path_format_arguments = { @@ -275,18 +284,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -297,9 +304,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -311,18 +321,16 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -333,9 +341,12 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -347,18 +358,16 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -368,14 +377,17 @@ def build_restart_request_initial( cloud_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RoleInstances] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -387,20 +399,18 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -412,14 +422,17 @@ def build_reimage_request_initial( cloud_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RoleInstances] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -431,20 +444,18 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -456,14 +467,17 @@ def build_rebuild_request_initial( cloud_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RoleInstances] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/rebuild") # pylint: disable=line-too-long path_format_arguments = { @@ -475,20 +489,18 @@ def build_rebuild_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -500,14 +512,17 @@ def build_delete_instances_request_initial( cloud_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RoleInstances] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -519,62 +534,61 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class CloudServicesOperations(object): # pylint: disable=too-many-public-methods - """CloudServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CloudServicesOperations: # 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.compute.v2020_10_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.compute.v2020_10_01_preview.ComputeManagementClient`'s + :attr:`cloud_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") + def _create_or_update_initial( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudService"] = None, + parameters: Optional[_models.CloudService] = None, **kwargs: Any - ) -> "_models.CloudService": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] + ) -> _models.CloudService: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] if parameters is not None: _json = self._serialize.body(parameters, 'CloudService') @@ -589,11 +603,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -623,9 +639,9 @@ def begin_create_or_update( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudService"] = None, + parameters: Optional[_models.CloudService] = None, **kwargs: Any - ) -> LROPoller["_models.CloudService"]: + ) -> LROPoller[_models.CloudService]: """Create or update a cloud service. Please note some properties can be set only during cloud service creation. @@ -649,37 +665,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_10_01_preview.models.CloudService] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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('CloudService', 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( @@ -696,17 +722,20 @@ def _update_initial( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudServiceUpdate"] = None, + parameters: Optional[_models.CloudServiceUpdate] = None, **kwargs: Any - ) -> "_models.CloudService": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] + ) -> _models.CloudService: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] if parameters is not None: _json = self._serialize.body(parameters, 'CloudServiceUpdate') @@ -721,11 +750,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -751,9 +782,9 @@ def begin_update( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudServiceUpdate"] = None, + parameters: Optional[_models.CloudServiceUpdate] = None, **kwargs: Any - ) -> LROPoller["_models.CloudService"]: + ) -> LROPoller[_models.CloudService]: """Update a cloud service. :param resource_group_name: Name of the resource group. @@ -776,37 +807,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_10_01_preview.models.CloudService] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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('CloudService', 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( @@ -825,13 +866,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements cloud_service_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', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -840,11 +884,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -886,20 +932,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-01-preview")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -909,8 +960,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -929,7 +986,7 @@ def get( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.CloudService": + ) -> _models.CloudService: """Display information about a cloud service. :param resource_group_name: Name of the resource group. @@ -941,13 +998,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_10_01_preview.models.CloudService :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] request = build_get_request( @@ -956,11 +1016,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -987,7 +1049,7 @@ def get_instance_view( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.CloudServiceInstanceView": + ) -> _models.CloudServiceInstanceView: """Gets the status of a cloud service. :param resource_group_name: Name of the resource group. @@ -999,13 +1061,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2020_10_01_preview.models.CloudServiceInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceInstanceView] request = build_get_instance_view_request( @@ -1014,11 +1079,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1043,7 +1110,7 @@ def get_instance_view( def list_all( self, **kwargs: Any - ) -> Iterable["_models.CloudServiceListResult"]: + ) -> Iterable[_models.CloudServiceListResult]: """Gets a list of all cloud services in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud Services. @@ -1055,13 +1122,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_10_01_preview.models.CloudServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1069,9 +1139,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1079,9 +1151,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1119,7 +1193,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.CloudServiceListResult"]: + ) -> Iterable[_models.CloudServiceListResult]: """Gets a list of all cloud services under a resource group. Use nextLink property in the response to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud Services. @@ -1133,13 +1207,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_10_01_preview.models.CloudServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1148,9 +1225,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1159,9 +1238,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1200,13 +1281,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1215,11 +1299,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1261,20 +1347,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1284,8 +1375,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1304,13 +1401,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1319,11 +1419,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1366,20 +1468,25 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1389,8 +1496,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1407,17 +1520,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1432,11 +1548,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1458,7 +1576,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more role instances in a cloud service. @@ -1481,23 +1599,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-10-01-preview")) # 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] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1507,8 +1630,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1525,17 +1654,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1550,11 +1682,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1576,7 +1710,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> LROPoller[None]: """Reimage asynchronous operation reinstalls the operating system on instances of web roles or @@ -1600,23 +1734,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-10-01-preview")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1626,8 +1765,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1644,17 +1789,20 @@ def _rebuild_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1669,11 +1817,13 @@ def _rebuild_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._rebuild_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1695,7 +1845,7 @@ def begin_rebuild( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> LROPoller[None]: """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker @@ -1720,23 +1870,28 @@ def begin_rebuild( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-10-01-preview")) # 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] + 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._rebuild_initial( + raw_result = self._rebuild_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1746,8 +1901,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1764,17 +1925,20 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1789,11 +1953,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1815,7 +1981,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> LROPoller[None]: """Deletes role instances in a cloud service. @@ -1838,23 +2004,28 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-10-01-preview")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1864,8 +2035,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_services_update_domain_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_services_update_domain_operations.py index 8729673102c8..bac3841f045a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_services_update_domain_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_cloud_services_update_domain_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_walk_update_domain_request_initial( update_domain: int, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.UpdateDomain] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_walk_update_domain_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,9 +83,12 @@ def build_get_update_domain_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,18 +101,16 @@ def build_get_update_domain_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -119,9 +121,12 @@ def build_list_update_domains_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = case_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-10-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains") # pylint: disable=line-too-long path_format_arguments = { @@ -133,59 +138,58 @@ def build_list_update_domains_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CloudServicesUpdateDomainOperations(object): - """CloudServicesUpdateDomainOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CloudServicesUpdateDomainOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_10_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.compute.v2020_10_01_preview.ComputeManagementClient`'s + :attr:`cloud_services_update_domain` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _walk_update_domain_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, update_domain: int, - parameters: Optional["_models.UpdateDomain"] = None, + parameters: Optional[_models.UpdateDomain] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-10-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'UpdateDomain') @@ -201,11 +205,13 @@ def _walk_update_domain_initial( # pylint: disable=inconsistent-return-statemen content_type=content_type, json=_json, template_url=self._walk_update_domain_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -228,7 +234,7 @@ def begin_walk_update_domain( # pylint: disable=inconsistent-return-statements resource_group_name: str, cloud_service_name: str, update_domain: int, - parameters: Optional["_models.UpdateDomain"] = None, + parameters: Optional[_models.UpdateDomain] = None, **kwargs: Any ) -> LROPoller[None]: """Updates the role instances in the specified update domain. @@ -255,17 +261,20 @@ def begin_walk_update_domain( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-10-01-preview")) # 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] + 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._walk_update_domain_initial( + raw_result = self._walk_update_domain_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, update_domain=update_domain, @@ -273,6 +282,8 @@ def begin_walk_update_domain( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -282,8 +293,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -303,7 +320,7 @@ def get_update_domain( cloud_service_name: str, update_domain: int, **kwargs: Any - ) -> "_models.UpdateDomain": + ) -> _models.UpdateDomain: """Gets the specified update domain of a cloud service. Use nextLink property in the response to get the next page of update domains. Do this till nextLink is null to fetch all the update domains. @@ -321,13 +338,16 @@ def get_update_domain( :rtype: ~azure.mgmt.compute.v2020_10_01_preview.models.UpdateDomain :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateDomain"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateDomain] request = build_get_update_domain_request( @@ -337,11 +357,13 @@ def get_update_domain( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_update_domain.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -368,7 +390,7 @@ def list_update_domains( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> Iterable["_models.UpdateDomainListResult"]: + ) -> Iterable[_models.UpdateDomainListResult]: """Gets a list of all update domains in a cloud service. :param resource_group_name: Name of the resource group. @@ -382,13 +404,16 @@ def list_update_domains( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_10_01_preview.models.UpdateDomainListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateDomainListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateDomainListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +423,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_update_domains.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -410,9 +437,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_10_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/_compute_management_client.py index 03a90c694921..07d96fa7ce97 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/_compute_management_client.py @@ -128,33 +128,87 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_restore_point = DiskRestorePointOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/_compute_management_client.py index dce00be65053..af7a2d86d500 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/_compute_management_client.py @@ -130,33 +130,87 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_restore_point = DiskRestorePointOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/__init__.py index f5a1c71fcb9f..a625cbfa8e55 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/__init__.py @@ -34,6 +34,9 @@ from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations from ._virtual_machine_scale_set_vm_run_commands_operations import VirtualMachineScaleSetVMRunCommandsOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', @@ -63,3 +66,5 @@ 'VirtualMachineRunCommandsOperations', 'VirtualMachineScaleSetVMRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_availability_sets_operations.py index dd852a8c458f..aacd49338167 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_dedicated_host_groups_operations.py index daa3b6e01aab..25e54ed59ea0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_dedicated_host_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostGroupsOperations: - """DedicatedHostGroupsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -137,14 +141,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -156,11 +163,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -199,13 +208,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,11 +226,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +256,7 @@ async def get( host_group_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -250,7 +264,7 @@ async def get( :param host_group_name: The name of the dedicated host group. :type host_group_name: str :param expand: The expand expression to apply on the operation. The response shows the list of - instance view of the dedicated hosts under the dedicated host group. Possible values are + instance view of the dedicated hosts under the dedicated host group. Known values are "instanceView" or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -258,13 +272,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -274,11 +291,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +323,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -317,13 +336,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -332,9 +354,11 @@ def prepare_request(next_link=None): 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: @@ -343,9 +367,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -382,7 +408,7 @@ async def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -393,13 +419,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -407,9 +436,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -417,9 +448,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_dedicated_hosts_operations.py index 1ed9a17ba399..868b6cd63644 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostsOperations: - """DedicatedHostsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('DedicatedHost', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -267,17 +286,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -285,20 +307,27 @@ async def begin_update( 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('DedicatedHost', 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( @@ -318,13 +347,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -334,11 +366,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,21 +417,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -407,8 +446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -429,7 +474,7 @@ async def get( host_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -438,21 +483,24 @@ async def get( :type host_group_name: str :param host_name: The name of the dedicated host. :type host_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedHost, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_12_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -463,11 +511,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -494,7 +544,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostListResult"]: + ) -> AsyncIterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -509,13 +559,16 @@ def list_by_host_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -525,9 +578,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -537,9 +592,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disk_accesses_operations.py index 8029d354615b..9161731de086 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskAccessesOperations: - """DiskAccessesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -340,11 +372,13 @@ async def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -626,7 +690,7 @@ async def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -640,13 +704,16 @@ async def get_private_link_resources( :rtype: ~azure.mgmt.compute.v2020_12_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -655,11 +722,13 @@ async def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -685,17 +754,20 @@ async def _update_a_private_endpoint_connection_initial( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.PrivateEndpointConnection] _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') @@ -708,11 +780,13 @@ async def _update_a_private_endpoint_connection_initial( content_type=content_type, json=_json, template_url=self._update_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -743,9 +817,9 @@ async def begin_update_a_private_endpoint_connection( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection under disk access resource, this can't be used to create a new private endpoint connection. @@ -775,17 +849,20 @@ async def begin_update_a_private_endpoint_connection( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.PrivateEndpointConnection] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_a_private_endpoint_connection_initial( + raw_result = await self._update_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -793,20 +870,27 @@ async def begin_update_a_private_endpoint_connection( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -826,7 +910,7 @@ async def get_a_private_endpoint_connection( disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about a private endpoint connection under a disk access resource. :param resource_group_name: The name of the resource group. @@ -842,13 +926,16 @@ async def get_a_private_endpoint_connection( :rtype: ~azure.mgmt.compute.v2020_12_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_a_private_endpoint_connection_request( @@ -858,11 +945,13 @@ async def get_a_private_endpoint_connection( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get_a_private_endpoint_connection.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -890,13 +979,16 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inco private_endpoint_connection_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_a_private_endpoint_connection_request_initial( @@ -906,11 +998,13 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inco private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -957,21 +1051,26 @@ async def begin_delete_a_private_endpoint_connection( # pylint: disable=inconsi :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_a_private_endpoint_connection_initial( + raw_result = await self._delete_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -981,8 +1080,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1001,7 +1106,7 @@ def list_private_endpoint_connections( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List information about private endpoint connections under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1017,13 +1122,16 @@ def list_private_endpoint_connections( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - 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: @@ -1033,9 +1141,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=self.list_private_endpoint_connections.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1045,9 +1155,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disk_encryption_sets_operations.py index 15b300a37ee8..8e5555cc6ef7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskEncryptionSetsOperations: - """DiskEncryptionSetsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -238,9 +257,9 @@ async def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -266,37 +285,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -315,7 +344,7 @@ async def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -329,13 +358,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -344,11 +376,13 @@ async def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -375,13 +409,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -390,11 +427,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,20 +477,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -461,8 +505,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -480,7 +530,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -492,13 +542,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -507,9 +560,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -518,9 +573,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -557,7 +614,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -567,13 +624,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -581,9 +641,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -591,9 +653,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -632,7 +696,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceUriList"]: + ) -> AsyncIterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -647,13 +711,16 @@ def list_associated_resources( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -663,9 +730,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_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,9 +744,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disk_restore_point_operations.py index 430e9a8b4aa8..3820cbd0e030 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disk_restore_point_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskRestorePointOperations: - """DiskRestorePointOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -55,7 +54,7 @@ async def get( vm_restore_point_name: str, disk_restore_point_name: str, **kwargs: Any - ) -> "_models.DiskRestorePoint": + ) -> _models.DiskRestorePoint: """Get disk restorePoint resource. :param resource_group_name: The name of the resource group. @@ -76,13 +75,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.DiskRestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePoint] request = build_get_request( @@ -93,11 +95,13 @@ async def get( disk_restore_point_name=disk_restore_point_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -125,7 +129,7 @@ def list_by_restore_point( restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskRestorePointList"]: + ) -> AsyncIterable[_models.DiskRestorePointList]: """Lists diskRestorePoints under a vmRestorePoint. :param resource_group_name: The name of the resource group. @@ -145,13 +149,16 @@ def list_by_restore_point( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskRestorePointList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePointList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePointList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -162,9 +169,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=self.list_by_restore_point.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -175,9 +184,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -216,17 +227,20 @@ async def _grant_access_initial( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -240,11 +254,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -274,9 +290,9 @@ async def begin_grant_access( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a diskRestorePoint. :param resource_group_name: The name of the resource group. @@ -308,17 +324,20 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, @@ -327,20 +346,27 @@ async def begin_grant_access( 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('AccessUri', 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( @@ -361,13 +387,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_restore_point_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -378,11 +407,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_restore_point_name=disk_restore_point_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -435,22 +466,27 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, disk_restore_point_name=disk_restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -460,8 +496,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disks_operations.py index c45574bfa8c0..124dbb2fc8fd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_images_operations.py index 56e3b0005d45..920e8a265bc9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_log_analytics_operations.py index b5609670eb79..8a7e7d7d3a73 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_operations.py index 12ae6914ebd3..5e2df4ccdc12 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_proximity_placement_groups_operations.py index d4001c5d19fe..c0511eb66536 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,7 +254,7 @@ async def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -255,13 +269,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -271,11 +288,13 @@ async def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -300,7 +319,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -310,13 +329,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -324,9 +346,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -334,9 +358,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -374,7 +400,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -386,13 +412,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,9 +430,11 @@ def prepare_request(next_link=None): 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: @@ -412,9 +443,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_snapshots_operations.py index a95822bbc15c..c09628ba5765 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_ssh_public_keys_operations.py index 8d2779444cb1..75757cdba71e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_ssh_public_keys_operations.py @@ -15,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 @@ -24,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SshPublicKeysOperations: - """SshPublicKeysOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -60,13 +59,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -74,9 +76,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -84,9 +88,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +130,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -137,13 +143,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -152,9 +161,11 @@ def prepare_request(next_link=None): 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: @@ -163,9 +174,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -203,9 +216,9 @@ async def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -219,14 +232,17 @@ async def create( :rtype: ~azure.mgmt.compute.v2020_12_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -238,11 +254,13 @@ async def create( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -272,9 +290,9 @@ async def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -288,14 +306,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -307,11 +328,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -350,13 +373,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -365,11 +391,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,7 +420,7 @@ async def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -404,13 +432,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -419,11 +450,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,7 +483,7 @@ async def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -464,13 +497,16 @@ async def generate_key_pair( :rtype: ~azure.mgmt.compute.v2020_12_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -479,11 +515,13 @@ async def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_usage_operations.py index 56d1f16f9a82..f31741cd25ad 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_extension_images_operations.py index 171c401316c7..5fd577732910 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_extensions_operations.py index b59a493eecc6..d6682401b0aa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_images_edge_zone_operations.py index 5f8ea9b25bac..3dbea50943d2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_images_edge_zone_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesEdgeZoneOperations: - """VirtualMachineImagesEdgeZoneOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +52,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. @@ -73,13 +72,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -92,11 +94,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -129,7 +133,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. @@ -156,13 +160,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -177,11 +184,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -209,7 +218,7 @@ async def list_offers( edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. @@ -224,13 +233,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -240,11 +252,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -271,7 +285,7 @@ async def list_publishers( location: str, edge_zone: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. @@ -283,13 +297,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -298,11 +315,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -331,7 +350,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. @@ -348,13 +367,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -365,11 +387,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_images_operations.py index 08894cc64d1e..a5fbcf3e67a2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_run_commands_operations.py index 4734b929d46e..d31f88462234 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -64,13 +63,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,7 +137,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -143,13 +149,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -158,11 +167,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,18 +199,21 @@ async def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -212,11 +226,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,11 +263,11 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -263,7 +279,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -280,16 +296,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -297,20 +316,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -328,18 +354,21 @@ async def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -352,11 +381,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,11 +414,11 @@ async def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -398,7 +429,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -415,16 +446,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -432,20 +466,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -465,13 +506,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -481,11 +525,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,21 +576,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -554,8 +605,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -576,7 +633,7 @@ async def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -592,13 +649,16 @@ async def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -609,11 +669,13 @@ async def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -641,7 +703,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -657,13 +719,16 @@ def list_by_virtual_machine( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -674,9 +739,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -687,9 +754,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index 016a68c70b9a..1f7cbc2a70de 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -189,17 +203,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -212,11 +229,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -276,17 +295,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -294,20 +316,27 @@ async def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -327,13 +356,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -343,11 +375,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,21 +426,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -416,8 +455,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -438,7 +483,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -516,13 +566,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -532,9 +585,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -544,9 +599,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index ca8dba02cc76..980948df7370 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,13 +292,16 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu vm_scale_set_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -276,11 +310,13 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,20 +360,25 @@ async def begin_start_extension_upgrade( # pylint: disable=inconsistent-return- :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_extension_upgrade_initial( + raw_result = await self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -347,8 +388,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -367,7 +414,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -379,13 +426,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2020_12_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -394,11 +444,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py index 237ccbb5c279..6762e06b8d7d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMExtensionsOperations: - """VirtualMachineScaleSetVMExtensionsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -51,17 +50,20 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -111,9 +115,9 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -161,20 +168,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -193,17 +207,20 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -217,11 +234,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -249,9 +268,9 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -280,17 +299,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -299,20 +321,27 @@ async def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -333,13 +362,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -350,11 +382,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -402,22 +436,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -427,8 +466,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -450,7 +495,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -468,13 +513,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -486,11 +534,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -519,7 +569,7 @@ async def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -535,13 +585,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -552,11 +605,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index e79fe3fec27a..8765c04aa74a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMRunCommandsOperations: - """VirtualMachineScaleSetVMRunCommandsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,18 +52,21 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -78,11 +80,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -114,11 +118,11 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -131,7 +135,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -148,16 +152,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -166,20 +173,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -198,18 +212,21 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -223,11 +240,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,11 +274,11 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -272,7 +291,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -289,16 +308,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -307,20 +329,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -341,13 +370,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -358,11 +390,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -410,22 +444,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -435,8 +474,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -458,7 +503,7 @@ async def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -476,13 +521,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_request( @@ -494,11 +542,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +577,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -545,13 +595,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -563,9 +616,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -577,9 +632,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index c9d72398a35c..8d67afe9a9ee 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -78,11 +80,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -132,17 +136,20 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -150,6 +157,8 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,13 +195,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -196,11 +214,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,21 +266,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -270,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -291,13 +322,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -307,11 +341,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,21 +394,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -382,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -401,17 +448,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -424,11 +474,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,9 +511,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -487,17 +539,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -505,20 +560,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -539,13 +601,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -556,11 +621,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -609,22 +676,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -634,8 +706,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -656,7 +734,7 @@ async def get( instance_id: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -665,21 +743,24 @@ async def get( :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. :type instance_id: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachineScaleSetVM, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -690,11 +771,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -722,7 +805,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -736,13 +819,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -752,11 +838,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -786,7 +874,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -810,13 +898,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -829,9 +920,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -844,9 +937,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -887,13 +982,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -904,11 +1002,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -960,22 +1060,27 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -985,8 +1090,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1006,13 +1117,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1022,11 +1136,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1071,21 +1187,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1095,8 +1216,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1116,13 +1243,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1132,11 +1262,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1181,21 +1313,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1205,8 +1342,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1226,13 +1369,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1242,11 +1388,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1292,21 +1440,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1316,8 +1469,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1338,7 +1497,7 @@ async def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -1357,13 +1516,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2020_12_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1374,11 +1536,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1406,13 +1570,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1422,11 +1589,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1471,21 +1640,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1495,8 +1669,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1530,13 +1710,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -1546,11 +1729,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1572,18 +1757,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1596,11 +1784,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1629,11 +1819,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1644,7 +1834,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2020_12_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1661,16 +1851,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1678,20 +1871,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_sets_operations.py index a87938166b9d..271637db7ac5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -151,11 +160,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -185,9 +196,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -210,37 +221,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -257,17 +278,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -279,11 +303,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +335,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -334,37 +360,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -384,13 +420,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -400,11 +439,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,21 +491,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -474,8 +520,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -494,7 +546,7 @@ async def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -506,13 +558,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -521,11 +576,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -550,17 +607,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -575,11 +635,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -601,7 +663,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -628,23 +690,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -654,8 +721,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -672,18 +745,21 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -696,11 +772,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat json=_json, force_deletion=force_deletion, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -722,7 +800,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: @@ -750,17 +828,20 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, @@ -768,6 +849,8 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -777,8 +860,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -797,7 +886,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -809,13 +898,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -824,11 +916,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -854,7 +948,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -866,13 +960,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -881,9 +978,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -892,9 +991,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -931,7 +1032,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -943,13 +1044,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -957,9 +1061,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -967,9 +1073,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1008,7 +1116,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1023,13 +1131,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1039,9 +1150,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1051,9 +1164,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1092,7 +1207,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1106,13 +1221,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1122,9 +1240,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1134,9 +1254,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1174,17 +1296,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1200,11 +1325,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1227,7 +1354,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1258,17 +1385,20 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -1276,6 +1406,8 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1285,8 +1417,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1303,17 +1441,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1328,11 +1469,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1354,7 +1497,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1379,23 +1522,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1405,8 +1553,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1423,17 +1577,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1448,11 +1605,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1474,7 +1633,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1499,23 +1658,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1525,8 +1689,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1543,17 +1713,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1568,11 +1741,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1594,7 +1769,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1620,23 +1795,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1646,8 +1826,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1664,17 +1850,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1689,11 +1878,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1715,7 +1906,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1743,23 +1934,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1769,8 +1965,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1787,17 +1989,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1809,11 +2014,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1835,7 +2042,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1859,23 +2066,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[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._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1885,8 +2097,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1903,17 +2121,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -1928,11 +2149,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1954,7 +2177,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -1980,23 +2203,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2006,8 +2234,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2024,17 +2258,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2049,11 +2286,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2075,7 +2314,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2101,23 +2340,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2127,8 +2371,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2148,7 +2398,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2164,13 +2414,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2020_12_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2180,11 +2433,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2210,7 +2465,7 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -2227,14 +2482,17 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret :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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] _json = self._serialize.body(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -2246,11 +2504,13 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2271,17 +2531,20 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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[None] _json = self._serialize.body(parameters, 'OrchestrationServiceStateInput') @@ -2293,11 +2556,13 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2319,7 +2584,7 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> AsyncLROPoller[None]: """Changes ServiceState property for a given service. @@ -2342,23 +2607,28 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[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._set_orchestration_service_state_initial( + raw_result = await self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -2368,8 +2638,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_sizes_operations.py index 37a5f2103b19..b458c9d93c3b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machines_operations.py index 35f7ea34ca8d..c283e9a346e5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2020_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.compute.v2020_12_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -338,37 +364,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -385,17 +421,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -407,11 +446,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -437,9 +478,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -462,37 +503,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -512,13 +563,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -528,11 +582,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -578,21 +634,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -602,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -623,28 +690,31 @@ async def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -654,11 +724,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -685,7 +757,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -697,13 +769,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -712,11 +787,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -743,13 +820,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -758,11 +838,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -805,20 +887,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -828,8 +915,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -848,13 +941,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -863,11 +959,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -910,20 +1008,25 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -933,8 +1036,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -970,13 +1079,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -985,11 +1097,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1011,7 +1125,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1024,13 +1138,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1039,9 +1156,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1050,9 +1169,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1090,7 +1211,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1104,13 +1225,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1119,9 +1243,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1130,9 +1256,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1171,7 +1299,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1186,13 +1314,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1202,9 +1333,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1214,9 +1347,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1256,13 +1391,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1272,11 +1410,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1324,21 +1464,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1348,8 +1493,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1368,13 +1519,16 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -1383,11 +1537,13 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1429,20 +1585,25 @@ async def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._reapply_initial( + raw_result = await self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1452,8 +1613,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1472,13 +1639,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1487,11 +1657,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1533,20 +1705,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1556,8 +1733,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1576,13 +1759,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1591,11 +1777,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1637,20 +1825,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1660,8 +1853,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1680,13 +1879,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1695,11 +1897,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1741,20 +1945,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1764,8 +1973,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1782,17 +1997,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -1807,11 +2025,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1833,7 +2053,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -1857,23 +2077,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_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-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[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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -1883,8 +2108,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1904,7 +2135,7 @@ async def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -1920,13 +2151,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2020_12_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1936,11 +2170,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1967,13 +2203,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1982,11 +2221,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2028,20 +2269,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2051,8 +2297,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2083,13 +2335,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2098,11 +2353,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2124,14 +2381,17 @@ async def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -2140,11 +2400,13 @@ async def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2173,7 +2435,7 @@ async def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -2194,34 +2456,44 @@ async def begin_assess_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = await self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -2238,17 +2510,20 @@ async def _install_patches_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineInstallPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineInstallPatchesResult"]] + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineInstallPatchesResult]] _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') @@ -2260,11 +2535,13 @@ async def _install_patches_initial( content_type=content_type, json=_json, template_url=self._install_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2292,9 +2569,9 @@ async def begin_install_patches( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineInstallPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. @@ -2318,37 +2595,47 @@ async def begin_install_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineInstallPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineInstallPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstallPatchesResult"] 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._install_patches_initial( + raw_result = await self._install_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineInstallPatchesResult', 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( @@ -2365,18 +2652,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2388,11 +2678,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2420,11 +2712,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2433,7 +2725,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2020_12_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2450,36 +2742,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2020_12_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/__init__.py index 3e7c193519c7..776842564bc0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/__init__.py @@ -316,7 +316,9 @@ VmDiskTypes, WindowsVMGuestPatchMode, ) - +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__ = [ 'AccessUri', 'AdditionalCapabilities', @@ -625,3 +627,5 @@ 'VmDiskTypes', 'WindowsVMGuestPatchMode', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/_compute_management_client_enums.py index 33c0ea1c2e2f..6ecf49b3ecdb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/_compute_management_client_enums.py @@ -7,17 +7,16 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" WRITE = "Write" -class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. """ @@ -25,7 +24,7 @@ class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CLASSIC = "Classic" ALIGNED = "Aligned" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -36,7 +35,7 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the software license type that will be applied to the VMs deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` @@ -47,13 +46,13 @@ class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" -class DiffDiskOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk option for operating system disk. """ LOCAL = "Local" -class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskPlacement(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk placement for operating system disk. This property can be used by user in the request to choose the location i.e, cache disk or resource disk space for Ephemeral OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer @@ -66,7 +65,7 @@ class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CACHE_DISK = "CacheDisk" RESOURCE_DISK = "ResourceDisk" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -89,7 +88,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the disk. UPLOAD = "Upload" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -102,7 +101,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class DiskDetachOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskDetachOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the detach behavior to be used while detaching a disk or which is already in the process of detachment from the virtual machine. Supported values: **ForceDetach**. :code:`
`:code:`
` detachOption: **ForceDetach** is applicable only for managed data @@ -116,7 +115,7 @@ class DiskDetachOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FORCE_DETACH = "ForceDetach" -class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted resources @@ -126,7 +125,7 @@ class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, SYSTEM_ASSIGNED = "SystemAssigned" NONE = "None" -class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -137,7 +136,7 @@ class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: of the keys is Customer managed and the other key is Platform managed. ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" -class DiskSecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskSecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the SecurityType of the VM. Applicable for OS disks only. """ @@ -145,7 +144,7 @@ class DiskSecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Module (vTPM). TRUSTED_LAUNCH = "TrustedLaunch" -class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible state of the disk. """ @@ -162,7 +161,7 @@ class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: A disk is created for upload and a write token has been issued for uploading to it. ACTIVE_UPLOAD = "ActiveUpload" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -183,7 +182,7 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: and dev/test that need storage resiliency against zone failures. STANDARD_SSD_ZRS = "StandardSSD_ZRS" -class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -197,7 +196,7 @@ class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the other key is Platform managed. ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" -class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExecutionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Script execution status. """ @@ -209,34 +208,34 @@ class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TIMED_OUT = "TimedOut" CANCELED = "Canceled" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class HyperVGenerationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type associated with a resource """ V1 = "V1" V2 = "V2" -class HyperVGenerationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type """ V1 = "V1" V2 = "V2" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -245,7 +244,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -254,7 +253,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class LinuxVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinuxVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patching to IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - @@ -265,7 +264,7 @@ class LinuxVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -274,7 +273,7 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Policy for accessing the disk via network. """ @@ -285,7 +284,7 @@ class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The disk cannot be exported. DENY_ALL = "DenyAll" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ @@ -294,27 +293,27 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: Specialized image. Contains already provisioned OS Disk. SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class OrchestrationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the orchestration mode for the virtual machine scale set. """ UNIFORM = "Uniform" FLEXIBLE = "Flexible" -class OrchestrationServiceNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the service. """ AUTOMATIC_REPAIRS = "AutomaticRepairs" -class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current state of the service. """ @@ -322,21 +321,21 @@ class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enu RUNNING = "Running" SUSPENDED = "Suspended" -class OrchestrationServiceStateAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceStateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The action to be performed. """ RESUME = "Resume" SUSPEND = "Suspend" -class PatchAssessmentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchAssessmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the availability of a given patch. """ UNKNOWN = "Unknown" AVAILABLE = "Available" -class PatchInstallationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchInstallationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the patch after the installation operation completed. """ @@ -347,7 +346,7 @@ class PatchInstallationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) NOT_SELECTED = "NotSelected" PENDING = "Pending" -class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", or "CompletedWithWarnings." @@ -359,7 +358,7 @@ class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -368,7 +367,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. """ @@ -376,7 +375,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -384,7 +383,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -393,7 +392,7 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -404,14 +403,14 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -420,7 +419,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not be enabled unless this property is set as TrustedLaunch. @@ -428,7 +427,7 @@ class SecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TRUSTED_LAUNCH = "TrustedLaunch" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -436,7 +435,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -447,7 +446,7 @@ class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E #: Standard zone redundant storage. STANDARD_ZRS = "Standard_ZRS" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -455,7 +454,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. StandardSSD_LRS uses Standard SSD. Premium_LRS uses Premium SSD. UltraSSD_LRS uses Ultra disk. @@ -473,7 +472,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PREMIUM_ZRS = "Premium_ZRS" STANDARD_SSD_ZRS = "StandardSSD_ZRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -485,7 +484,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -493,7 +492,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -502,14 +501,14 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for the Azure Spot VM/VMSS """ DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for a standalone virtual machine or the virtual machines in the scale set. :code:`
`:code:`
` 'Low' enum will be deprecated in the future, please use 'Spot' as the enum to deploy Azure Spot VM/VMSS. @@ -519,20 +518,20 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E LOW = "Low" SPOT = "Spot" -class VirtualMachineScaleSetScaleInRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "Default" OLDEST_VM = "OldestVM" NEWEST_VM = "NewestVM" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. :code:`
`:code:`
` The enum data type is currently deprecated and will be removed by December 23rd 2023. :code:`
`:code:`
` Recommended way to get the list of available sizes is using these APIs: @@ -714,20 +713,20 @@ class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) STANDARD_NV12 = "Standard_NV12" STANDARD_NV24 = "Standard_NV24" -class VmDiskTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VmDiskTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """VM disk types which are disallowed. """ NONE = "None" UNMANAGED = "Unmanaged" -class VMGuestPatchClassificationLinux(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchClassificationLinux(str, Enum, metaclass=CaseInsensitiveEnumMeta): CRITICAL = "Critical" SECURITY = "Security" OTHER = "Other" -class VMGuestPatchClassificationWindows(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchClassificationWindows(str, Enum, metaclass=CaseInsensitiveEnumMeta): CRITICAL = "Critical" SECURITY = "Security" @@ -738,7 +737,7 @@ class VMGuestPatchClassificationWindows(with_metaclass(CaseInsensitiveEnumMeta, TOOLS = "Tools" UPDATES = "Updates" -class VMGuestPatchRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the reboot requirements of the patch. """ @@ -747,7 +746,7 @@ class VMGuestPatchRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, En ALWAYS_REQUIRES_REBOOT = "AlwaysRequiresReboot" CAN_REQUEST_REBOOT = "CanRequestReboot" -class VMGuestPatchRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines when it is acceptable to reboot a VM during a software update operation. """ @@ -755,7 +754,7 @@ class VMGuestPatchRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enu NEVER = "Never" ALWAYS = "Always" -class VMGuestPatchRebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reboot state of the VM following completion of the operation. """ @@ -766,7 +765,7 @@ class VMGuestPatchRebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" COMPLETED = "Completed" -class WindowsVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WindowsVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patching to IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of patches to a virtual machine. You do this by applying patches manually inside the VM. In this diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/_models_py3.py index 2c0a20d00b61..128eccd3d33c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -83,7 +85,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2020_12_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -104,7 +106,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -117,7 +119,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2020_12_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -185,8 +187,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -488,11 +490,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -550,7 +552,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -632,11 +634,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -672,8 +674,8 @@ class AvailablePatchSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2020_12_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -946,8 +948,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :vartype create_option: str or ~azure.mgmt.compute.v2020_12_01.models.DiskCreateOption :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -996,10 +998,10 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, - gallery_image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, + gallery_image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, upload_size_bytes: Optional[int] = None, @@ -1008,7 +1010,7 @@ def __init__( ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload". :paramtype create_option: str or ~azure.mgmt.compute.v2020_12_01.models.DiskCreateOption :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -1067,8 +1069,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1079,7 +1080,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2020_12_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1106,8 +1107,8 @@ class DataDisk(msrest.serialization.Model): force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. :code:`
`:code:`
` This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data - disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Possible - values include: "ForceDetach". + disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Known values + are: "ForceDetach". :vartype detach_option: str or ~azure.mgmt.compute.v2020_12_01.models.DiskDetachOptionTypes """ @@ -1138,16 +1139,16 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, to_be_detached: Optional[bool] = None, - detach_option: Optional[Union[str, "DiskDetachOptionTypes"]] = None, + detach_option: Optional[Union[str, "_models.DiskDetachOptionTypes"]] = None, **kwargs ): """ @@ -1166,8 +1167,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1178,7 +1178,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2020_12_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1197,8 +1197,8 @@ def __init__( force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. :code:`
`:code:`
` This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data - disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Possible - values include: "ForceDetach". + disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Known values + are: "ForceDetach". :paramtype detach_option: str or ~azure.mgmt.compute.v2020_12_01.models.DiskDetachOptionTypes """ super(DataDisk, self).__init__(**kwargs) @@ -1279,7 +1279,7 @@ class DedicatedHost(Resource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2020_12_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1324,11 +1324,11 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1349,7 +1349,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2020_12_01.models.DedicatedHostLicenseTypes """ @@ -1415,7 +1415,7 @@ class DedicatedHostAvailableCapacity(msrest.serialization.Model): def __init__( self, *, - allocatable_v_ms: Optional[List["DedicatedHostAllocatableVM"]] = None, + allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs ): """ @@ -1537,7 +1537,7 @@ class DedicatedHostGroupInstanceView(msrest.serialization.Model): def __init__( self, *, - hosts: Optional[List["DedicatedHostInstanceViewWithName"]] = None, + hosts: Optional[List["_models.DedicatedHostInstanceViewWithName"]] = None, **kwargs ): """ @@ -1573,7 +1573,7 @@ class DedicatedHostGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHostGroup"], + value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs ): @@ -1691,8 +1691,8 @@ class DedicatedHostInstanceView(msrest.serialization.Model): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1740,8 +1740,8 @@ class DedicatedHostInstanceViewWithName(DedicatedHostInstanceView): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1779,7 +1779,7 @@ class DedicatedHostListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHost"], + value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs ): @@ -1816,7 +1816,7 @@ class DedicatedHostUpdate(UpdateResource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2020_12_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1853,7 +1853,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1869,7 +1869,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2020_12_01.models.DedicatedHostLicenseTypes """ @@ -1901,7 +1901,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -1918,8 +1918,8 @@ def __init__( class DiffDiskSettings(msrest.serialization.Model): """Describes the parameters of ephemeral disk settings that can be specified for operating system disk. :code:`
`:code:`
` NOTE: The ephemeral disk settings can only be specified for managed disk. - :ivar option: Specifies the ephemeral disk settings for operating system disk. Possible values - include: "Local". + :ivar option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :vartype option: str or ~azure.mgmt.compute.v2020_12_01.models.DiffDiskOptions :ivar placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -1928,7 +1928,7 @@ class DiffDiskSettings(msrest.serialization.Model): Refer to VM size documentation for Windows VM at https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes to check which VM sizes - exposes a cache disk. Possible values include: "CacheDisk", "ResourceDisk". + exposes a cache disk. Known values are: "CacheDisk", "ResourceDisk". :vartype placement: str or ~azure.mgmt.compute.v2020_12_01.models.DiffDiskPlacement """ @@ -1940,13 +1940,13 @@ class DiffDiskSettings(msrest.serialization.Model): def __init__( self, *, - option: Optional[Union[str, "DiffDiskOptions"]] = None, - placement: Optional[Union[str, "DiffDiskPlacement"]] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, + placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, **kwargs ): """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. Possible - values include: "Local". + :keyword option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :paramtype option: str or ~azure.mgmt.compute.v2020_12_01.models.DiffDiskOptions :keyword placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -1955,7 +1955,7 @@ def __init__( Refer to VM size documentation for Windows VM at https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/en-us/azure/virtual-machines/linux/sizes to check which VM sizes - exposes a cache disk. Possible values include: "CacheDisk", "ResourceDisk". + exposes a cache disk. Known values are: "CacheDisk", "ResourceDisk". :paramtype placement: str or ~azure.mgmt.compute.v2020_12_01.models.DiffDiskPlacement """ super(DiffDiskSettings, self).__init__(**kwargs) @@ -1966,8 +1966,7 @@ def __init__( class DisallowedConfiguration(msrest.serialization.Model): """Specifies the disallowed configuration for a virtual machine image. - :ivar vm_disk_type: VM disk types which are disallowed. Possible values include: "None", - "Unmanaged". + :ivar vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :vartype vm_disk_type: str or ~azure.mgmt.compute.v2020_12_01.models.VmDiskTypes """ @@ -1978,11 +1977,11 @@ class DisallowedConfiguration(msrest.serialization.Model): def __init__( self, *, - vm_disk_type: Optional[Union[str, "VmDiskTypes"]] = None, + vm_disk_type: Optional[Union[str, "_models.VmDiskTypes"]] = None, **kwargs ): """ - :keyword vm_disk_type: VM disk types which are disallowed. Possible values include: "None", + :keyword vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :paramtype vm_disk_type: str or ~azure.mgmt.compute.v2020_12_01.models.VmDiskTypes """ @@ -2023,10 +2022,10 @@ class Disk(Resource): :vartype extended_location: ~azure.mgmt.compute.v2020_12_01.models.ExtendedLocation :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: @@ -2064,7 +2063,7 @@ class Disk(Resource): mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. :vartype disk_m_bps_read_only: long - :ivar disk_state: The state of the disk. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", "Reserved", "ActiveSAS", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2020_12_01.models.DiskState :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed @@ -2076,8 +2075,8 @@ class Disk(Resource): :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should be set to a value greater than one for disks to allow attaching them to multiple VMs. :vartype share_info: list[~azure.mgmt.compute.v2020_12_01.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_12_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -2157,27 +2156,27 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - creation_data: Optional["CreationData"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, supports_hibernation: Optional[bool] = None, - security_profile: Optional["DiskSecurityProfile"] = None, + security_profile: Optional["_models.DiskSecurityProfile"] = None, **kwargs ): """ @@ -2193,10 +2192,10 @@ def __init__( :keyword extended_location: The extended location where the disk will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2020_12_01.models.ExtendedLocation - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: @@ -2234,8 +2233,8 @@ def __init__( :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_12_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -2377,7 +2376,7 @@ class DiskAccessList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskAccess"], + value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs ): @@ -2438,8 +2437,8 @@ class DiskEncryptionSet(Resource): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2020_12_01.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype encryption_type: str or ~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSetType :ivar active_key: The key vault key which is currently used by this disk encryption set. :vartype active_key: ~azure.mgmt.compute.v2020_12_01.models.KeyForDiskEncryptionSet @@ -2487,9 +2486,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyForDiskEncryptionSet"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, rotation_to_latest_key_version_enabled: Optional[bool] = None, **kwargs ): @@ -2501,8 +2500,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2020_12_01.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype encryption_type: str or ~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSetType :keyword active_key: The key vault key which is currently used by this disk encryption set. :paramtype active_key: ~azure.mgmt.compute.v2020_12_01.models.KeyForDiskEncryptionSet @@ -2544,7 +2543,7 @@ class DiskEncryptionSetList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskEncryptionSet"], + value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs ): @@ -2630,8 +2629,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -2658,8 +2657,8 @@ class DiskEncryptionSetUpdate(msrest.serialization.Model): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2020_12_01.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype encryption_type: str or ~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSetType :ivar active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and Snapshots. @@ -2681,9 +2680,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyForDiskEncryptionSet"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, rotation_to_latest_key_version_enabled: Optional[bool] = None, **kwargs ): @@ -2693,8 +2692,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2020_12_01.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype encryption_type: str or ~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSetType :keyword active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and Snapshots. @@ -2734,8 +2733,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2778,7 +2777,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -2846,10 +2845,10 @@ class DiskRestorePoint(ProxyOnlyResource): :vartype time_created: ~datetime.datetime :ivar source_resource_id: arm id of source disk. :vartype source_resource_id: str - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. @@ -2895,14 +2894,14 @@ class DiskRestorePoint(ProxyOnlyResource): def __init__( self, *, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, supports_hibernation: Optional[bool] = None, **kwargs ): """ :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. @@ -2946,7 +2945,7 @@ class DiskRestorePointList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskRestorePoint"], + value: List["_models.DiskRestorePoint"], next_link: Optional[str] = None, **kwargs ): @@ -2965,8 +2964,8 @@ def __init__( class DiskSecurityProfile(msrest.serialization.Model): """Contains the security related information for the resource. - :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Possible values include: "TrustedLaunch". + :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. Known + values are: "TrustedLaunch". :vartype security_type: str or ~azure.mgmt.compute.v2020_12_01.models.DiskSecurityTypes """ @@ -2977,12 +2976,12 @@ class DiskSecurityProfile(msrest.serialization.Model): def __init__( self, *, - security_type: Optional[Union[str, "DiskSecurityTypes"]] = None, + security_type: Optional[Union[str, "_models.DiskSecurityTypes"]] = None, **kwargs ): """ :keyword security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Possible values include: "TrustedLaunch". + Known values are: "TrustedLaunch". :paramtype security_type: str or ~azure.mgmt.compute.v2020_12_01.models.DiskSecurityTypes """ super(DiskSecurityProfile, self).__init__(**kwargs) @@ -2994,8 +2993,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype name: str or ~azure.mgmt.compute.v2020_12_01.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -3013,11 +3012,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2020_12_01.models.DiskStorageAccountTypes """ @@ -3036,7 +3035,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, or StandardSSD_ZRS. :vartype sku: ~azure.mgmt.compute.v2020_12_01.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -3067,8 +3066,8 @@ class DiskUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2020_12_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_12_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -3118,21 +3117,21 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, max_shares: Optional[int] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, - purchase_plan: Optional["PurchasePlan"] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, supports_hibernation: Optional[bool] = None, **kwargs ): @@ -3142,7 +3141,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, or StandardSSD_ZRS. :paramtype sku: ~azure.mgmt.compute.v2020_12_01.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -3173,8 +3172,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2020_12_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_12_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -3219,7 +3218,7 @@ class Encryption(msrest.serialization.Model): :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Possible values include: + :ivar type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype type: str or ~azure.mgmt.compute.v2020_12_01.models.EncryptionType @@ -3234,14 +3233,14 @@ def __init__( self, *, disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "EncryptionType"]] = None, + type: Optional[Union[str, "_models.EncryptionType"]] = None, **kwargs ): """ :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Possible values include: + :keyword type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype type: str or ~azure.mgmt.compute.v2020_12_01.models.EncryptionType @@ -3259,7 +3258,7 @@ class EncryptionSetIdentity(msrest.serialization.Model): :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted - resources to lose access to the keys. Possible values include: "SystemAssigned", "None". + resources to lose access to the keys. Known values are: "SystemAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSetIdentityType :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a @@ -3285,15 +3284,14 @@ class EncryptionSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "DiskEncryptionSetIdentityType"]] = None, + type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, **kwargs ): """ :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the - encrypted resources to lose access to the keys. Possible values include: "SystemAssigned", - "None". + encrypted resources to lose access to the keys. Known values are: "SystemAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSetIdentityType """ super(EncryptionSetIdentity, self).__init__(**kwargs) @@ -3335,7 +3333,7 @@ def __init__( self, *, enabled: bool, - encryption_settings: Optional[List["EncryptionSettingsElement"]] = None, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, encryption_settings_version: Optional[str] = None, **kwargs ): @@ -3377,8 +3375,8 @@ class EncryptionSettingsElement(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -3399,7 +3397,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.compute.v2020_12_01.models.ExtendedLocationTypes """ @@ -3412,13 +3410,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.compute.v2020_12_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -3431,7 +3429,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read", "Write". + :ivar access: Required. Known values are: "None", "Read", "Write". :vartype access: str or ~azure.mgmt.compute.v2020_12_01.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -3450,12 +3448,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read", "Write". + :keyword access: Required. Known values are: "None", "Read", "Write". :paramtype access: str or ~azure.mgmt.compute.v2020_12_01.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -3479,7 +3477,7 @@ class HardwareProfile(msrest.serialization.Model): `_. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The - available VM sizes depend on region and availability set. Possible values include: "Basic_A0", + available VM sizes depend on region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", @@ -3524,7 +3522,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -3539,7 +3537,7 @@ def __init__( `_. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The - available VM sizes depend on region and availability set. Possible values include: "Basic_A0", + available VM sizes depend on region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", @@ -3608,8 +3606,8 @@ class Image(Resource): :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Possible - values include: "V1", "V2". + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGenerationTypes """ @@ -3640,10 +3638,10 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -3661,7 +3659,7 @@ def __init__( from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the user to specify the property if we cannot deduce it from the source managed - resource. Possible values include: "V1", "V2". + resource. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGenerationTypes """ @@ -3685,16 +3683,15 @@ class ImageDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_12_01.models.StorageAccountTypes @@ -3717,13 +3714,13 @@ class ImageDisk(msrest.serialization.Model): def __init__( self, *, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3736,16 +3733,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_12_01.models.StorageAccountTypes @@ -3778,16 +3774,15 @@ class ImageDataDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_12_01.models.StorageAccountTypes @@ -3820,13 +3815,13 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3839,16 +3834,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_12_01.models.StorageAccountTypes @@ -3931,7 +3925,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -3961,16 +3955,15 @@ class ImageOSDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_12_01.models.StorageAccountTypes @@ -3980,10 +3973,10 @@ class ImageOSDisk(ImageDisk): ~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSetParameters :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemStateTypes """ @@ -4007,15 +4000,15 @@ class ImageOSDisk(ImageDisk): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -4028,16 +4021,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_12_01.models.StorageAccountTypes @@ -4047,11 +4039,10 @@ def __init__( ~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSetParameters :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemStateTypes """ super(ImageOSDisk, self).__init__(snapshot=snapshot, managed_disk=managed_disk, blob_uri=blob_uri, caching=caching, disk_size_gb=disk_size_gb, storage_account_type=storage_account_type, disk_encryption_set=disk_encryption_set, **kwargs) @@ -4160,8 +4151,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -4202,8 +4193,8 @@ class ImageUpdate(UpdateResource): :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Possible - values include: "V1", "V2". + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGenerationTypes """ @@ -4224,9 +4215,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -4240,7 +4231,7 @@ def __init__( from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the user to specify the property if we cannot deduce it from the source managed - resource. Possible values include: "V1", "V2". + resource. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGenerationTypes """ @@ -4288,7 +4279,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2020_12_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -4310,7 +4301,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -4319,7 +4310,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2020_12_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -4363,7 +4354,7 @@ def __init__( self, *, key_url: str, - source_vault: Optional["SourceVault"] = None, + source_vault: Optional["_models.SourceVault"] = None, **kwargs ): """ @@ -4404,7 +4395,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -4443,7 +4434,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -4483,7 +4474,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -4522,7 +4513,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -4543,8 +4534,8 @@ class LastPatchInstallationSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2020_12_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -4651,9 +4642,9 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, provision_vm_agent: Optional[bool] = None, - patch_settings: Optional["LinuxPatchSettings"] = None, + patch_settings: Optional["_models.LinuxPatchSettings"] = None, **kwargs ): """ @@ -4706,7 +4697,7 @@ class LinuxParameters(msrest.serialization.Model): def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "VMGuestPatchClassificationLinux"]]] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationLinux"]]] = None, package_name_masks_to_include: Optional[List[str]] = None, package_name_masks_to_exclude: Optional[List[str]] = None, maintenance_run_id: Optional[str] = None, @@ -4741,7 +4732,7 @@ class LinuxPatchSettings(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. Possible values include: "ImageDefault", + The property provisionVMAgent must be true. Known values are: "ImageDefault", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2020_12_01.models.LinuxVMGuestPatchMode """ @@ -4753,7 +4744,7 @@ class LinuxPatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "LinuxVMGuestPatchMode"]] = None, + patch_mode: Optional[Union[str, "_models.LinuxVMGuestPatchMode"]] = None, **kwargs ): """ @@ -4761,7 +4752,7 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. Possible values include: "ImageDefault", + The property provisionVMAgent must be true. Known values are: "ImageDefault", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2020_12_01.models.LinuxVMGuestPatchMode """ @@ -4793,7 +4784,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -4961,8 +4952,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2020_12_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -4987,7 +4978,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -5003,8 +4994,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2020_12_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -5027,9 +5018,8 @@ class ManagedDiskParameters(SubResource): :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can - only be used with data disks, it cannot be used with OS Disk. Possible values include: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", - "StandardSSD_ZRS". + only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", + "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_12_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -5048,8 +5038,8 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -5057,7 +5047,7 @@ def __init__( :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS - can only be used with data disks, it cannot be used with OS Disk. Possible values include: + can only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or @@ -5121,7 +5111,7 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, **kwargs ): """ @@ -5139,11 +5129,9 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :ivar service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2020_12_01.models.OrchestrationServiceNames - :ivar action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :ivar action: Required. The action to be performed. Known values are: "Resume", "Suspend". :vartype action: str or ~azure.mgmt.compute.v2020_12_01.models.OrchestrationServiceStateAction """ @@ -5160,17 +5148,15 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): def __init__( self, *, - service_name: Union[str, "OrchestrationServiceNames"], - action: Union[str, "OrchestrationServiceStateAction"], + service_name: Union[str, "_models.OrchestrationServiceNames"], + action: Union[str, "_models.OrchestrationServiceStateAction"], **kwargs ): """ - :keyword service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :keyword service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :paramtype service_name: str or ~azure.mgmt.compute.v2020_12_01.models.OrchestrationServiceNames - :keyword action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :keyword action: Required. The action to be performed. Known values are: "Resume", "Suspend". :paramtype action: str or ~azure.mgmt.compute.v2020_12_01.models.OrchestrationServiceStateAction """ @@ -5184,9 +5170,9 @@ class OrchestrationServiceSummary(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar service_name: The name of the service. Possible values include: "AutomaticRepairs". + :ivar service_name: The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2020_12_01.models.OrchestrationServiceNames - :ivar service_state: The current state of the service. Possible values include: "NotRunning", + :ivar service_state: The current state of the service. Known values are: "NotRunning", "Running", "Suspended". :vartype service_state: str or ~azure.mgmt.compute.v2020_12_01.models.OrchestrationServiceState """ @@ -5219,8 +5205,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -5236,8 +5222,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -5251,7 +5236,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2020_12_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5282,24 +5267,24 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -5315,8 +5300,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -5330,7 +5314,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2020_12_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5358,8 +5342,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes """ @@ -5374,12 +5358,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -5480,9 +5464,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, require_guest_provision_signal: Optional[bool] = None, **kwargs @@ -5590,8 +5574,7 @@ class PatchInstallationDetail(msrest.serialization.Model): :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] :ivar installation_state: The state of the patch after the installation operation completed. - Possible values include: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", - "Pending". + Known values are: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", "Pending". :vartype installation_state: str or ~azure.mgmt.compute.v2020_12_01.models.PatchInstallationState """ @@ -5640,8 +5623,8 @@ class PatchSettings(msrest.serialization.Model): **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2020_12_01.models.WindowsVMGuestPatchMode :ivar enable_hotpatching: Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must @@ -5657,7 +5640,7 @@ class PatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "WindowsVMGuestPatchMode"]] = None, + patch_mode: Optional[Union[str, "_models.WindowsVMGuestPatchMode"]] = None, enable_hotpatching: Optional[bool] = None, **kwargs ): @@ -5670,8 +5653,8 @@ def __init__( **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2020_12_01.models.WindowsVMGuestPatchMode :keyword enable_hotpatching: Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must @@ -5776,7 +5759,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype private_link_service_connection_state: ~azure.mgmt.compute.v2020_12_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.compute.v2020_12_01.models.PrivateEndpointConnectionProvisioningState """ @@ -5801,7 +5784,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): def __init__( self, *, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -5837,7 +5820,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -5922,7 +5905,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -5937,7 +5920,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.compute.v2020_12_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -5956,14 +5939,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, actions_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.compute.v2020_12_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -6025,7 +6008,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2020_12_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -6072,8 +6055,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -6084,7 +6067,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2020_12_01.models.ProximityPlacementGroupType :keyword colocation_status: Describes colocation status of the Proximity Placement Group. @@ -6121,7 +6104,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -6321,7 +6304,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_user_agent: Group query result by User Agent. :vartype group_by_user_agent: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2020_12_01.models.IntervalInMins """ @@ -6350,7 +6333,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -6377,7 +6360,7 @@ def __init__( :keyword group_by_user_agent: Group query result by User Agent. :paramtype group_by_user_agent: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2020_12_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, group_by_client_application_id=group_by_client_application_id, group_by_user_agent=group_by_user_agent, **kwargs) @@ -6640,13 +6623,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2020_12_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2020_12_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -6759,8 +6742,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -6789,7 +6771,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -6799,8 +6781,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -6824,8 +6805,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -6861,11 +6841,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -6873,8 +6853,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -6920,7 +6899,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -7001,7 +6980,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -7084,7 +7063,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -7123,7 +7102,7 @@ class ScaleInPolicy(msrest.serialization.Model): def __init__( self, *, - rules: Optional[List[Union[str, "VirtualMachineScaleSetScaleInRules"]]] = None, + rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, **kwargs ): """ @@ -7164,7 +7143,7 @@ class ScheduledEventsProfile(msrest.serialization.Model): def __init__( self, *, - terminate_notification_profile: Optional["TerminateNotificationProfile"] = None, + terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs ): """ @@ -7191,8 +7170,7 @@ class SecurityProfile(msrest.serialization.Model): :vartype encryption_at_host: bool :ivar security_type: Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not - be enabled unless this property is set as TrustedLaunch. Possible values include: - "TrustedLaunch". + be enabled unless this property is set as TrustedLaunch. Known values are: "TrustedLaunch". :vartype security_type: str or ~azure.mgmt.compute.v2020_12_01.models.SecurityTypes """ @@ -7205,9 +7183,9 @@ class SecurityProfile(msrest.serialization.Model): def __init__( self, *, - uefi_settings: Optional["UefiSettings"] = None, + uefi_settings: Optional["_models.UefiSettings"] = None, encryption_at_host: Optional[bool] = None, - security_type: Optional[Union[str, "SecurityTypes"]] = None, + security_type: Optional[Union[str, "_models.SecurityTypes"]] = None, **kwargs ): """ @@ -7222,8 +7200,7 @@ def __init__( :paramtype encryption_at_host: bool :keyword security_type: Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not - be enabled unless this property is set as TrustedLaunch. Possible values include: - "TrustedLaunch". + be enabled unless this property is set as TrustedLaunch. Known values are: "TrustedLaunch". :paramtype security_type: str or ~azure.mgmt.compute.v2020_12_01.models.SecurityTypes """ super(SecurityProfile, self).__init__(**kwargs) @@ -7330,10 +7307,10 @@ class Snapshot(Resource): :vartype extended_location: ~azure.mgmt.compute.v2020_12_01.models.ExtendedLocation :ivar time_created: The time when the snapshot was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. @@ -7348,7 +7325,7 @@ class Snapshot(Resource): :vartype disk_size_gb: int :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. :vartype disk_size_bytes: long - :ivar disk_state: The state of the snapshot. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the snapshot. Known values are: "Unattached", "Attached", "Reserved", "ActiveSAS", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2020_12_01.models.DiskState :ivar unique_id: Unique Guid identifying the resource. @@ -7365,8 +7342,8 @@ class Snapshot(Resource): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2020_12_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_12_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -7420,17 +7397,17 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - extended_location: Optional["ExtendedLocation"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, incremental: Optional[bool] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, supports_hibernation: Optional[bool] = None, **kwargs @@ -7447,10 +7424,10 @@ def __init__( :keyword extended_location: The extended location where the snapshot will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2020_12_01.models.ExtendedLocation - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. @@ -7473,8 +7450,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2020_12_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_12_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -7529,7 +7506,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -7550,8 +7527,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2020_12_01.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -7569,12 +7545,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2020_12_01.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -7591,7 +7566,7 @@ class SnapshotUpdate(msrest.serialization.Model): an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. :vartype sku: ~azure.mgmt.compute.v2020_12_01.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -7605,8 +7580,8 @@ class SnapshotUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2020_12_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2020_12_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -7631,12 +7606,12 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, supports_hibernation: Optional[bool] = None, **kwargs @@ -7648,7 +7623,7 @@ def __init__( is an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. :paramtype sku: ~azure.mgmt.compute.v2020_12_01.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -7662,8 +7637,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2020_12_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2020_12_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -7723,7 +7698,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -7918,7 +7893,7 @@ class SshPublicKeysGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["SshPublicKeyResource"], + value: List["_models.SshPublicKeyResource"], next_link: Optional[str] = None, **kwargs ): @@ -8000,9 +7975,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -8074,7 +8049,7 @@ def __init__( self, *, id: Optional[str] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -8287,7 +8262,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2020_12_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2020_12_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2020_12_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -8334,7 +8309,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2020_12_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -8374,8 +8349,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2020_12_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -8395,9 +8370,9 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["AutomaticOSUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, + automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, **kwargs ): """ @@ -8405,8 +8380,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2020_12_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -8460,7 +8435,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -8614,8 +8589,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -8732,14 +8707,13 @@ class VirtualMachine(Resource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2020_12_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -8836,25 +8810,25 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, platform_fault_domain: Optional[int] = None, @@ -8923,15 +8897,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2020_12_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -9021,8 +8994,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -9047,8 +9020,8 @@ class VirtualMachineAssessPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2020_12_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -9295,7 +9268,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -9364,7 +9337,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -9501,8 +9474,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -9539,7 +9512,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -9680,8 +9653,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2020_12_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -9705,15 +9678,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2020_12_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -9767,7 +9740,7 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, **kwargs ): """ @@ -9818,8 +9791,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2020_12_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: "V1", - "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGenerationTypes :ivar disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -9856,14 +9828,14 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - plan: Optional["PurchasePlanAutoGenerated"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, - disallowed: Optional["DisallowedConfiguration"] = None, - features: Optional[List["VirtualMachineImageFeature"]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + plan: Optional["_models.PurchasePlanAutoGenerated"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, + automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, + disallowed: Optional["_models.DisallowedConfiguration"] = None, + features: Optional[List["_models.VirtualMachineImageFeature"]] = None, **kwargs ): """ @@ -9890,8 +9862,7 @@ def __init__( image. :paramtype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2020_12_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: - "V1", "V2". + :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGenerationTypes :keyword disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -9951,7 +9922,7 @@ class VirtualMachineInstallPatchesParameters(msrest.serialization.Model): run. It must be an ISO 8601-compliant duration string such as PT4H (4 hours). :vartype maximum_duration: str :ivar reboot_setting: Required. Defines when it is acceptable to reboot a VM during a software - update operation. Possible values include: "IfRequired", "Never", "Always". + update operation. Known values are: "IfRequired", "Never", "Always". :vartype reboot_setting: str or ~azure.mgmt.compute.v2020_12_01.models.VMGuestPatchRebootSetting :ivar windows_parameters: Input for InstallPatches on a Windows VM, as directly received by the @@ -9978,9 +9949,9 @@ def __init__( self, *, maximum_duration: str, - reboot_setting: Union[str, "VMGuestPatchRebootSetting"], - windows_parameters: Optional["WindowsParameters"] = None, - linux_parameters: Optional["LinuxParameters"] = None, + reboot_setting: Union[str, "_models.VMGuestPatchRebootSetting"], + windows_parameters: Optional["_models.WindowsParameters"] = None, + linux_parameters: Optional["_models.LinuxParameters"] = None, **kwargs ): """ @@ -9988,7 +9959,7 @@ def __init__( will run. It must be an ISO 8601-compliant duration string such as PT4H (4 hours). :paramtype maximum_duration: str :keyword reboot_setting: Required. Defines when it is acceptable to reboot a VM during a - software update operation. Possible values include: "IfRequired", "Never", "Always". + software update operation. Known values are: "IfRequired", "Never", "Always". :paramtype reboot_setting: str or ~azure.mgmt.compute.v2020_12_01.models.VMGuestPatchRebootSetting :keyword windows_parameters: Input for InstallPatches on a Windows VM, as directly received by @@ -10012,14 +9983,14 @@ class VirtualMachineInstallPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Failed", "Succeeded", "Unknown" or - "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2020_12_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. :vartype installation_activity_id: str - :ivar reboot_status: The reboot state of the VM following completion of the operation. Possible - values include: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". + :ivar reboot_status: The reboot state of the VM following completion of the operation. Known + values are: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". :vartype reboot_status: str or ~azure.mgmt.compute.v2020_12_01.models.VMGuestPatchRebootStatus :ivar maintenance_window_exceeded: Whether the operation ran out of time before it completed all its intended actions. @@ -10114,8 +10085,8 @@ class VirtualMachineInstanceView(msrest.serialization.Model): :vartype os_name: str :ivar os_version: The version of Operating System running on the virtual machine. :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGenerationType :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. :vartype rdp_thumb_print: str @@ -10179,15 +10150,15 @@ def __init__( computer_name: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationType"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, - patch_status: Optional["VirtualMachinePatchStatus"] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, + patch_status: Optional["_models.VirtualMachinePatchStatus"] = None, **kwargs ): """ @@ -10202,7 +10173,7 @@ def __init__( :keyword os_version: The version of Operating System running on the virtual machine. :paramtype os_version: str :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2020_12_01.models.HyperVGenerationType :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. @@ -10270,7 +10241,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -10316,8 +10287,8 @@ class VirtualMachinePatchStatus(msrest.serialization.Model): def __init__( self, *, - available_patch_summary: Optional["AvailablePatchSummary"] = None, - last_patch_installation_summary: Optional["LastPatchInstallationSummary"] = None, + available_patch_summary: Optional["_models.AvailablePatchSummary"] = None, + last_patch_installation_summary: Optional["_models.LastPatchInstallationSummary"] = None, **kwargs ): """ @@ -10443,9 +10414,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -10500,7 +10471,7 @@ def __init__( class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): """The instance view of a virtual machine run command. - :ivar execution_state: Script execution status. Possible values include: "Unknown", "Pending", + :ivar execution_state: Script execution status. Known values are: "Unknown", "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :vartype execution_state: str or ~azure.mgmt.compute.v2020_12_01.models.ExecutionState :ivar execution_message: Communicate script configuration errors or execution messages. @@ -10533,19 +10504,19 @@ class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): def __init__( self, *, - execution_state: Optional[Union[str, "ExecutionState"]] = None, + execution_state: Optional[Union[str, "_models.ExecutionState"]] = None, execution_message: Optional[str] = None, exit_code: Optional[int] = None, output: Optional[str] = None, error: Optional[str] = None, start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ - :keyword execution_state: Script execution status. Possible values include: "Unknown", - "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". + :keyword execution_state: Script execution status. Known values are: "Unknown", "Pending", + "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :paramtype execution_state: str or ~azure.mgmt.compute.v2020_12_01.models.ExecutionState :keyword execution_message: Communicate script configuration errors or execution messages. :paramtype execution_message: str @@ -10635,7 +10606,7 @@ class VirtualMachineRunCommandsListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineRunCommand"], + value: List["_models.VirtualMachineRunCommand"], next_link: Optional[str] = None, **kwargs ): @@ -10711,9 +10682,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -10838,7 +10809,7 @@ class VirtualMachineScaleSet(Resource): chosen for removal when a Virtual Machine Scale Set is scaled-in. :vartype scale_in_policy: ~azure.mgmt.compute.v2020_12_01.models.ScaleInPolicy :ivar orchestration_mode: Specifies the orchestration mode for the virtual machine scale set. - Possible values include: "Uniform", "Flexible". + Known values are: "Uniform", "Flexible". :vartype orchestration_mode: str or ~azure.mgmt.compute.v2020_12_01.models.OrchestrationMode """ @@ -10884,24 +10855,24 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - orchestration_mode: Optional[Union[str, "OrchestrationMode"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + orchestration_mode: Optional[Union[str, "_models.OrchestrationMode"]] = None, **kwargs ): """ @@ -10965,7 +10936,7 @@ def __init__( chosen for removal when a Virtual Machine Scale Set is scaled-in. :paramtype scale_in_policy: ~azure.mgmt.compute.v2020_12_01.models.ScaleInPolicy :keyword orchestration_mode: Specifies the orchestration mode for the virtual machine scale - set. Possible values include: "Uniform", "Flexible". + set. Known values are: "Uniform", "Flexible". :paramtype orchestration_mode: str or ~azure.mgmt.compute.v2020_12_01.models.OrchestrationMode """ super(VirtualMachineScaleSet, self).__init__(location=location, tags=tags, **kwargs) @@ -11005,14 +10976,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2020_12_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -11052,12 +11022,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -11072,14 +11042,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2020_12_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -11254,7 +11223,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -11291,7 +11260,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, extensions_time_budget: Optional[str] = None, **kwargs ): @@ -11443,7 +11412,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2020_12_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine @@ -11468,15 +11437,15 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2020_12_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual @@ -11559,7 +11528,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -11620,7 +11589,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2020_12_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -11664,14 +11633,14 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -11689,7 +11658,7 @@ def __init__( ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2020_12_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -11781,7 +11750,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -11822,7 +11791,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -11862,7 +11831,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -11902,7 +11871,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -11922,8 +11891,8 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): """Describes the parameters of a ScaleSet managed disk. :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2020_12_01.models.StorageAccountTypes @@ -11941,14 +11910,14 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2020_12_01.models.StorageAccountTypes @@ -12015,9 +11984,9 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -12101,8 +12070,8 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -12129,8 +12098,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -12139,8 +12107,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2020_12_01.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -12151,8 +12119,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2020_12_01.models.VirtualHardDisk @@ -12184,16 +12152,16 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -12202,8 +12170,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -12212,8 +12179,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2020_12_01.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -12225,7 +12192,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2020_12_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2020_12_01.models.VirtualHardDisk @@ -12324,9 +12291,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -12413,7 +12380,7 @@ class VirtualMachineScaleSetPublicIPAddressConfiguration(msrest.serialization.Mo :vartype public_ip_prefix: ~azure.mgmt.compute.v2020_12_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2020_12_01.models.IPVersion """ @@ -12435,10 +12402,10 @@ def __init__( *, name: str, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersion"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, **kwargs ): """ @@ -12455,7 +12422,7 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2020_12_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2020_12_01.models.IPVersion """ super(VirtualMachineScaleSetPublicIPAddressConfiguration, self).__init__(**kwargs) @@ -12613,8 +12580,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -12676,9 +12642,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -12769,18 +12735,18 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - proximity_placement_group: Optional["SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -12858,7 +12824,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2020_12_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -12892,14 +12858,14 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -12917,7 +12883,7 @@ def __init__( ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2020_12_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -12992,9 +12958,9 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, **kwargs ): @@ -13052,8 +13018,8 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, **kwargs ): """ @@ -13073,7 +13039,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -13105,16 +13071,16 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2020_12_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -13166,9 +13132,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -13211,7 +13177,7 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, **kwargs ): """ @@ -13250,9 +13216,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -13314,15 +13280,15 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, **kwargs ): """ @@ -13506,18 +13472,18 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - network_profile_configuration: Optional["VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, - protection_policy: Optional["VirtualMachineScaleSetVMProtectionPolicy"] = None, + protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, **kwargs ): """ @@ -13678,7 +13644,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -13737,7 +13703,7 @@ class VirtualMachineScaleSetVMExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineScaleSetVMExtension"]] = None, + value: Optional[List["_models.VirtualMachineScaleSetVMExtension"]] = None, **kwargs ): """ @@ -14013,12 +13979,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -14089,7 +14055,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -14120,7 +14086,7 @@ class VirtualMachineScaleSetVMNetworkProfileConfiguration(msrest.serialization.M def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -14167,15 +14133,14 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -14203,17 +14168,17 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, **kwargs ): """ @@ -14249,15 +14214,14 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -14397,7 +14361,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -14423,7 +14387,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype kb_id: str :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] - :ivar reboot_behavior: Describes the reboot requirements of the patch. Possible values include: + :ivar reboot_behavior: Describes the reboot requirements of the patch. Known values are: "Unknown", "NeverReboots", "AlwaysRequiresReboot", "CanRequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.compute.v2020_12_01.models.VMGuestPatchRebootBehavior @@ -14434,7 +14398,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype published_date: ~datetime.datetime :ivar last_modified_date_time: The UTC timestamp of the last update to this patch record. :vartype last_modified_date_time: ~datetime.datetime - :ivar assessment_state: Describes the availability of a given patch. Possible values include: + :ivar assessment_state: Describes the availability of a given patch. Known values are: "Unknown", "Available". :vartype assessment_state: str or ~azure.mgmt.compute.v2020_12_01.models.PatchAssessmentState """ @@ -14578,14 +14542,13 @@ class VirtualMachineUpdate(UpdateResource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2020_12_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -14670,24 +14633,24 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, platform_fault_domain: Optional[int] = None, @@ -14752,15 +14715,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2020_12_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -14902,9 +14864,9 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - patch_settings: Optional["PatchSettings"] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + patch_settings: Optional["_models.PatchSettings"] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -14973,7 +14935,7 @@ class WindowsParameters(msrest.serialization.Model): def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "VMGuestPatchClassificationWindows"]]] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationWindows"]]] = None, kb_numbers_to_include: Optional[List[str]] = None, kb_numbers_to_exclude: Optional[List[str]] = None, exclude_kbs_requiring_reboot: Optional[bool] = None, @@ -15018,7 +14980,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -15033,7 +14995,7 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :vartype protocol: str or ~azure.mgmt.compute.v2020_12_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as @@ -15054,13 +15016,13 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2020_12_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/__init__.py index f5a1c71fcb9f..a625cbfa8e55 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/__init__.py @@ -34,6 +34,9 @@ from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations from ._virtual_machine_scale_set_vm_run_commands_operations import VirtualMachineScaleSetVMRunCommandsOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', @@ -63,3 +66,5 @@ 'VirtualMachineRunCommandsOperations', 'VirtualMachineScaleSetVMRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_availability_sets_operations.py index d2f9caf85b2c..925663cc9385 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +190,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -199,20 +205,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -235,18 +242,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -257,9 +262,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -271,51 +279,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -329,14 +333,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -348,11 +355,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -378,9 +387,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -394,14 +403,17 @@ def update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -413,11 +425,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,13 +470,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -471,11 +488,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -498,7 +517,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -510,13 +529,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -525,11 +547,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -555,7 +579,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -568,13 +592,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -583,9 +610,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +623,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -634,7 +665,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -646,13 +677,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +695,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -672,9 +708,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -713,7 +751,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -728,13 +766,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -756,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_dedicated_host_groups_operations.py index 2c4edf2db6a5..6c8a2fc2c954 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_dedicated_host_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +172,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -190,9 +193,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -203,18 +209,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -223,9 +227,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") path_format_arguments = { @@ -235,51 +242,47 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostGroupsOperations(object): - """DedicatedHostGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -295,14 +298,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -314,11 +320,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -348,9 +356,9 @@ def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -364,14 +372,17 @@ def update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -383,11 +394,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -426,13 +439,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -441,11 +457,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -469,7 +487,7 @@ def get( host_group_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -477,7 +495,7 @@ def get( :param host_group_name: The name of the dedicated host group. :type host_group_name: str :param expand: The expand expression to apply on the operation. The response shows the list of - instance view of the dedicated hosts under the dedicated host group. Possible values are + instance view of the dedicated hosts under the dedicated host group. Known values are "instanceView" or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response @@ -485,13 +503,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -501,11 +522,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -531,7 +554,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -544,13 +567,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -559,9 +585,11 @@ def prepare_request(next_link=None): 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: @@ -570,9 +598,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -609,7 +639,7 @@ def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -620,13 +650,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -634,9 +667,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -644,9 +679,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_dedicated_hosts_operations.py index a0913c8d8ee2..871451483fe8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHost] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_by_host_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_by_host_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostsOperations(object): - """DedicatedHostsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -341,17 +348,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -359,20 +369,27 @@ def begin_create_or_update( 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('DedicatedHost', 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( @@ -390,17 +407,20 @@ def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -413,11 +433,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -444,9 +466,9 @@ def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -470,17 +492,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -488,20 +513,27 @@ def begin_update( 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('DedicatedHost', 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( @@ -521,13 +553,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements host_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -537,11 +572,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -586,21 +623,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -610,8 +652,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -632,7 +680,7 @@ def get( host_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -641,21 +689,24 @@ def get( :type host_group_name: str :param host_name: The name of the dedicated host. :type host_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DedicatedHost, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_12_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -666,11 +717,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +750,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostListResult"]: + ) -> Iterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -712,13 +765,16 @@ def list_by_host_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -728,9 +784,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -740,9 +798,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disk_accesses_operations.py index a5e09f0e3bb2..67b6effdc958 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccess] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccessUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_get_private_link_resources_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,18 +284,16 @@ def build_get_private_link_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -297,14 +304,17 @@ def build_update_a_private_endpoint_connection_request_initial( disk_access_name: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -317,20 +327,18 @@ def build_update_a_private_endpoint_connection_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -344,9 +352,12 @@ def build_get_a_private_endpoint_connection_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -359,18 +370,16 @@ def build_get_a_private_endpoint_connection_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -382,9 +391,12 @@ def build_delete_a_private_endpoint_connection_request_initial( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -397,18 +409,16 @@ def build_delete_a_private_endpoint_connection_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -419,9 +429,12 @@ def build_list_private_endpoint_connections_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections") # pylint: disable=line-too-long path_format_arguments = { @@ -433,58 +446,57 @@ def build_list_private_endpoint_connections_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskAccessesOperations(object): - """DiskAccessesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -496,11 +508,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,9 +544,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -555,37 +569,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -602,17 +626,20 @@ def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -624,11 +651,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -658,9 +687,9 @@ def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -683,37 +712,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -732,7 +771,7 @@ def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -746,13 +785,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -761,11 +803,13 @@ def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -792,13 +836,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -807,11 +854,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -855,20 +904,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -878,8 +932,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -897,7 +957,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -907,13 +967,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -922,9 +985,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -933,9 +998,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -972,7 +1039,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -980,13 +1047,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -994,9 +1064,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1004,9 +1076,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1045,7 +1119,7 @@ def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -1059,13 +1133,16 @@ def get_private_link_resources( :rtype: ~azure.mgmt.compute.v2020_12_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -1074,11 +1151,13 @@ def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1104,17 +1183,20 @@ def _update_a_private_endpoint_connection_initial( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.PrivateEndpointConnection] _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') @@ -1127,11 +1209,13 @@ def _update_a_private_endpoint_connection_initial( content_type=content_type, json=_json, template_url=self._update_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1162,9 +1246,9 @@ def begin_update_a_private_endpoint_connection( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection under disk access resource, this can't be used to create a new private endpoint connection. @@ -1194,17 +1278,20 @@ def begin_update_a_private_endpoint_connection( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.PrivateEndpointConnection] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_a_private_endpoint_connection_initial( + raw_result = self._update_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -1212,20 +1299,27 @@ def begin_update_a_private_endpoint_connection( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -1245,7 +1339,7 @@ def get_a_private_endpoint_connection( disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about a private endpoint connection under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1261,13 +1355,16 @@ def get_a_private_endpoint_connection( :rtype: ~azure.mgmt.compute.v2020_12_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_a_private_endpoint_connection_request( @@ -1277,11 +1374,13 @@ def get_a_private_endpoint_connection( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get_a_private_endpoint_connection.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1309,13 +1408,16 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsiste private_endpoint_connection_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_a_private_endpoint_connection_request_initial( @@ -1325,11 +1427,13 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsiste private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1376,21 +1480,26 @@ def begin_delete_a_private_endpoint_connection( # pylint: disable=inconsistent- :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_a_private_endpoint_connection_initial( + raw_result = self._delete_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1400,8 +1509,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1420,7 +1535,7 @@ def list_private_endpoint_connections( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List information about private endpoint connections under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1436,13 +1551,16 @@ def list_private_endpoint_connections( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - 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: @@ -1452,9 +1570,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=self.list_private_endpoint_connections.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1464,9 +1584,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disk_encryption_sets_operations.py index 64b29979d9b1..a4e7c09b4924 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_list_associated_resources_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,58 +284,57 @@ def build_list_associated_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskEncryptionSetsOperations(object): - """DiskEncryptionSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -338,11 +346,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -372,9 +382,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -399,37 +409,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -446,17 +466,20 @@ def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -468,11 +491,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,9 +527,9 @@ def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -529,37 +554,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -578,7 +613,7 @@ def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -592,13 +627,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -607,11 +645,13 @@ def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -638,13 +678,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -653,11 +696,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -701,20 +746,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -724,8 +774,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -743,7 +799,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -755,13 +811,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -770,9 +829,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -781,9 +842,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -820,7 +883,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -830,13 +893,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -844,9 +910,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -854,9 +922,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -895,7 +965,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> Iterable["_models.ResourceUriList"]: + ) -> Iterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -909,13 +979,16 @@ def list_associated_resources( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -925,9 +998,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -937,9 +1012,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disk_restore_point_operations.py index 3322a73274c2..c011e5a2d923 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disk_restore_point_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +37,12 @@ def build_get_request( disk_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,18 +56,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -76,9 +77,12 @@ def build_list_by_restore_point_request( vm_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints") # pylint: disable=line-too-long path_format_arguments = { @@ -91,18 +95,16 @@ def build_list_by_restore_point_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -114,14 +116,17 @@ def build_grant_access_request_initial( vm_restore_point_name: str, disk_restore_point_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -135,20 +140,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -163,9 +166,12 @@ def build_revoke_access_request_initial( disk_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -179,42 +185,38 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class DiskRestorePointOperations(object): - """DiskRestorePointOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskRestorePointOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -224,7 +226,7 @@ def get( vm_restore_point_name: str, disk_restore_point_name: str, **kwargs: Any - ) -> "_models.DiskRestorePoint": + ) -> _models.DiskRestorePoint: """Get disk restorePoint resource. :param resource_group_name: The name of the resource group. @@ -245,13 +247,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.DiskRestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePoint] request = build_get_request( @@ -262,11 +267,13 @@ def get( disk_restore_point_name=disk_restore_point_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -294,7 +301,7 @@ def list_by_restore_point( restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> Iterable["_models.DiskRestorePointList"]: + ) -> Iterable[_models.DiskRestorePointList]: """Lists diskRestorePoints under a vmRestorePoint. :param resource_group_name: The name of the resource group. @@ -314,13 +321,16 @@ def list_by_restore_point( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskRestorePointList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePointList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePointList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -331,9 +341,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=self.list_by_restore_point.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -344,9 +356,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -385,17 +399,20 @@ def _grant_access_initial( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -409,11 +426,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -443,9 +462,9 @@ def begin_grant_access( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a diskRestorePoint. :param resource_group_name: The name of the resource group. @@ -476,17 +495,20 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, @@ -495,20 +517,27 @@ def begin_grant_access( 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('AccessUri', 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( @@ -529,13 +558,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_restore_point_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -546,11 +578,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_restore_point_name=disk_restore_point_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -603,22 +637,27 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, disk_restore_point_name=disk_restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -628,8 +667,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disks_operations.py index 74234baa3f42..1bb9648914aa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_images_operations.py index 83cb4bba0c3e..127f193655c7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -155,9 +157,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +174,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -192,9 +195,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -205,18 +211,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +229,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -237,58 +244,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] _json = self._serialize.body(parameters, 'Image') @@ -300,11 +306,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -334,9 +342,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -357,37 +365,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -404,17 +422,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -426,11 +447,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -460,9 +483,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -483,37 +506,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -532,13 +565,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -547,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,20 +631,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -616,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -637,7 +686,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -651,13 +700,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -667,11 +719,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -707,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -722,9 +779,11 @@ def prepare_request(next_link=None): 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: @@ -733,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -772,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -781,13 +842,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -805,9 +871,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_log_analytics_operations.py index 9f5795911db3..0890394fec26 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_operations.py index eb0d2517c447..3364a95fc0cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_proximity_placement_groups_operations.py index dc1c6be7d190..2d95a900ec38 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( include_colocation_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +172,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if include_colocation_status is not None: - _query_parameters['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -189,9 +192,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -235,51 +242,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -293,14 +296,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -312,11 +318,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -346,9 +354,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -362,14 +370,17 @@ def update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -381,11 +392,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -424,13 +437,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -439,11 +455,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -467,7 +485,7 @@ def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -482,13 +500,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -498,11 +519,13 @@ def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +550,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -537,13 +560,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -551,9 +577,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -561,9 +589,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -601,7 +631,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -613,13 +643,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -628,9 +661,11 @@ def prepare_request(next_link=None): 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: @@ -639,9 +674,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_snapshots_operations.py index 50fc452c69da..6a37e842b1b1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_ssh_public_keys_operations.py index 230d5147b69c..1912eb5c1e0f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_ssh_public_keys_operations.py @@ -16,12 +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 .. 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,9 +31,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") path_format_arguments = { @@ -43,18 +46,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -64,9 +65,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys") # pylint: disable=line-too-long path_format_arguments = { @@ -77,18 +81,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -98,14 +100,17 @@ def build_create_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -117,20 +122,18 @@ def build_create_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -142,14 +145,17 @@ def build_update_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyUpdateResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -161,20 +167,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -187,8 +191,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -200,13 +205,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -217,9 +221,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -231,18 +238,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -253,9 +258,12 @@ def build_generate_key_pair_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair") # pylint: disable=line-too-long path_format_arguments = { @@ -267,48 +275,44 @@ def build_generate_key_pair_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class SshPublicKeysOperations(object): - """SshPublicKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -319,13 +323,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -333,9 +340,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -343,9 +352,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -383,7 +394,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -396,13 +407,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -411,9 +425,11 @@ def prepare_request(next_link=None): 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: @@ -422,9 +438,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -462,9 +480,9 @@ def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -478,14 +496,17 @@ def create( :rtype: ~azure.mgmt.compute.v2020_12_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -497,11 +518,13 @@ def create( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -531,9 +554,9 @@ def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -547,14 +570,17 @@ def update( :rtype: ~azure.mgmt.compute.v2020_12_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -566,11 +592,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -609,13 +637,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -624,11 +655,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -651,7 +684,7 @@ def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -663,13 +696,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -678,11 +714,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -709,7 +747,7 @@ def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -723,13 +761,16 @@ def generate_key_pair( :rtype: ~azure.mgmt.compute.v2020_12_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -738,11 +779,13 @@ def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_usage_operations.py index aeefd7e9ed3e..67a42ecc2283 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_extension_images_operations.py index c6c6d5568667..65caa32f83c1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_extensions_operations.py index ecf055e6430a..f0ded7800538 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,8 +129,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -141,13 +144,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -161,9 +163,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -176,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -202,9 +205,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -216,61 +222,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -283,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -318,9 +325,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -347,17 +354,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -365,20 +375,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -396,17 +413,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -419,11 +439,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,9 +472,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -479,17 +501,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -497,20 +522,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -530,13 +562,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -546,11 +581,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,21 +632,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -619,8 +661,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -641,7 +689,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -657,13 +705,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -674,11 +725,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -706,7 +759,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -720,13 +773,16 @@ def list( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -736,11 +792,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_images_edge_zone_operations.py index afe8275d6e48..4a4fa6c4ce9c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_images_edge_zone_operations.py @@ -15,6 +15,7 @@ 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 @@ -35,9 +36,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,18 +57,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -82,9 +84,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -99,24 +104,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -128,9 +131,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +149,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -165,9 +169,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -179,18 +186,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +208,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -219,42 +227,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesEdgeZoneOperations(object): - """VirtualMachineImagesEdgeZoneOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesEdgeZoneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -266,7 +270,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. @@ -286,13 +290,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -305,11 +312,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -342,7 +351,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. @@ -369,13 +378,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -390,11 +402,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -422,7 +436,7 @@ def list_offers( edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. @@ -437,13 +451,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -453,11 +470,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -484,7 +503,7 @@ def list_publishers( location: str, edge_zone: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. @@ -496,13 +515,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -511,11 +533,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -544,7 +568,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. @@ -561,13 +585,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -578,11 +605,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_images_operations.py index 04cfbc751888..c7a8ef24c0ba 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_run_commands_operations.py index 5f752b286e74..3790e64910d8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -69,9 +70,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -83,18 +87,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -105,14 +107,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -125,20 +130,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -151,14 +154,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,20 +177,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -198,9 +202,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -213,18 +220,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -238,9 +243,12 @@ def build_get_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -253,20 +261,18 @@ def build_get_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -279,9 +285,12 @@ def build_list_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -293,51 +302,47 @@ def build_list_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -349,13 +354,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +372,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -375,9 +385,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -416,7 +428,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -428,13 +440,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -443,11 +458,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -473,18 +490,21 @@ def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -497,11 +517,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,11 +554,11 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -548,7 +570,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -565,16 +587,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -582,20 +607,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -613,18 +645,21 @@ def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -637,11 +672,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -668,11 +705,11 @@ def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -683,7 +720,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -700,16 +737,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -717,20 +757,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -750,13 +797,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -766,11 +816,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,21 +867,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -839,8 +896,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -861,7 +924,7 @@ def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -877,13 +940,16 @@ def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -894,11 +960,13 @@ def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -926,7 +994,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -942,13 +1010,16 @@ def list_by_virtual_machine( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -959,9 +1030,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -972,9 +1045,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_extensions_operations.py index d2feeaf85765..2c4f3f1f1df1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -345,17 +352,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -363,20 +373,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -394,17 +411,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -417,11 +437,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +474,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -481,17 +503,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -499,20 +524,27 @@ def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -532,13 +564,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -548,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -597,21 +634,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -621,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -643,7 +691,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -659,13 +707,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -676,11 +727,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -707,7 +760,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -721,13 +774,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -737,9 +793,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -749,9 +807,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index af747b6d24cd..08e43058d80c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,8 +34,9 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -46,13 +48,12 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -63,8 +64,9 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -76,13 +78,12 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -93,8 +94,9 @@ def build_start_extension_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -106,13 +108,12 @@ def build_start_extension_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -123,9 +124,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -137,42 +141,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -180,13 +180,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -195,11 +198,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,20 +246,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -264,8 +274,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -284,13 +300,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -299,11 +318,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,20 +368,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -370,8 +396,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -390,13 +422,16 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -405,11 +440,13 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -453,20 +490,25 @@ def begin_start_extension_upgrade( # pylint: disable=inconsistent-return-statem :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_extension_upgrade_initial( + raw_result = self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -476,8 +518,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -496,7 +544,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -508,13 +556,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2020_12_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -523,11 +574,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py index c580fb394378..5d3762010838 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -56,20 +59,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -83,14 +84,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -104,20 +108,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -132,9 +134,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -148,18 +153,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -174,9 +177,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -190,20 +196,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -217,9 +221,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -232,44 +239,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMExtensionsOperations(object): - """VirtualMachineScaleSetVMExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -277,17 +280,20 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -301,11 +307,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -368,17 +376,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -387,20 +398,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -419,17 +437,20 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -443,11 +464,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -475,9 +498,9 @@ def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -506,17 +529,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -525,20 +551,27 @@ def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -559,13 +592,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -576,11 +612,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -628,22 +666,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -653,8 +696,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -676,7 +725,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -694,13 +743,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -712,11 +764,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -745,7 +799,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -761,13 +815,16 @@ def list( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -778,11 +835,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index b254a8f8ea3a..0e312f63d8ba 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -133,9 +135,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -149,18 +154,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -175,9 +178,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -191,20 +197,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -218,9 +222,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -233,44 +240,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMRunCommandsOperations(object): - """VirtualMachineScaleSetVMRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -278,18 +281,21 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -303,11 +309,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -339,11 +347,11 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -356,7 +364,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -373,16 +381,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -423,18 +441,21 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,11 +503,11 @@ def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -497,7 +520,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -514,16 +537,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -532,20 +558,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -566,13 +599,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -583,11 +619,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,22 +673,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -660,8 +703,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -683,7 +732,7 @@ def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -701,13 +750,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_request( @@ -719,11 +771,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -752,7 +806,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -770,13 +824,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -788,9 +845,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -802,9 +861,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_vms_operations.py index 63d21ba7f65c..ceb44d98f908 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,13 +35,15 @@ def build_reimage_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -54,19 +56,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,8 +80,9 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -94,13 +95,12 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -112,8 +112,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -126,13 +127,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -143,14 +143,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -163,20 +166,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -192,8 +193,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -206,15 +208,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -228,9 +229,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -243,20 +247,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -268,9 +270,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -283,18 +288,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -309,9 +312,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -323,24 +329,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -354,8 +358,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -368,15 +373,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -388,8 +392,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -402,13 +407,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -420,8 +424,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -434,13 +439,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -452,8 +456,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -466,13 +471,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -486,9 +490,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -501,20 +508,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -526,8 +531,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -540,13 +546,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -558,8 +563,9 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -572,13 +578,12 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -589,14 +594,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -609,63 +617,62 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -681,11 +688,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -708,7 +717,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -735,17 +744,20 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -753,6 +765,8 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -762,8 +776,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -783,13 +803,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -799,11 +822,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -849,21 +874,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -873,8 +903,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -894,13 +930,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -910,11 +949,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -961,21 +1002,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -985,8 +1031,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1004,17 +1056,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -1027,11 +1082,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1062,9 +1119,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1090,17 +1147,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1108,20 +1168,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1142,13 +1209,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1159,11 +1229,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1212,22 +1284,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1237,8 +1314,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1259,7 +1342,7 @@ def get( instance_id: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1268,21 +1351,24 @@ def get( :type vm_scale_set_name: str :param instance_id: The instance ID of the virtual machine. :type instance_id: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachineScaleSetVM, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1293,11 +1379,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1325,7 +1413,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1339,13 +1427,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1355,11 +1446,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1389,7 +1482,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1413,13 +1506,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1432,9 +1528,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1447,9 +1545,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1490,13 +1590,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1507,11 +1610,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1563,22 +1668,27 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1588,8 +1698,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1609,13 +1725,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1625,11 +1744,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1674,21 +1795,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1698,8 +1824,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1719,13 +1851,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1735,11 +1870,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1784,21 +1921,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1808,8 +1950,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1829,13 +1977,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1845,11 +1996,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1895,21 +2048,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1919,8 +2077,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1941,7 +2105,7 @@ def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -1960,13 +2124,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2020_12_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1977,11 +2144,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2009,13 +2178,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2025,11 +2197,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2074,21 +2248,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2098,8 +2277,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2133,13 +2318,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2149,11 +2337,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2175,18 +2365,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2199,11 +2392,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2232,11 +2427,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2247,7 +2442,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2020_12_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2263,16 +2458,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2280,20 +2478,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_sets_operations.py index 3594c0b98f85..305cf863f30f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -159,8 +162,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,15 +176,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -191,9 +194,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -205,18 +211,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -226,13 +230,15 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -244,19 +250,17 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -268,14 +272,16 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -287,21 +293,19 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -314,9 +318,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -328,18 +335,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -349,9 +354,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -362,18 +370,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -382,9 +388,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -394,18 +403,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -416,9 +423,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -430,18 +440,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -452,9 +460,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -466,18 +477,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -487,14 +496,16 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -506,21 +517,19 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -532,13 +541,15 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -550,19 +561,17 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -574,13 +583,15 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -592,19 +603,17 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -616,13 +625,15 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -634,19 +645,17 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -658,13 +667,15 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -676,19 +687,17 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -700,13 +709,15 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -718,19 +729,17 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -742,13 +751,15 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -760,19 +771,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -784,13 +793,15 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -802,19 +813,17 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -829,9 +838,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( platform_update_domain: int, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -843,19 +855,17 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -865,13 +875,15 @@ def build_convert_to_single_placement_group_request( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VMScaleSetConvertToSinglePlacementGroupInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup") # pylint: disable=line-too-long path_format_arguments = { @@ -883,19 +895,17 @@ def build_convert_to_single_placement_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -907,13 +917,15 @@ def build_set_orchestration_service_state_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.OrchestrationServiceStateInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState") # pylint: disable=line-too-long path_format_arguments = { @@ -925,52 +937,48 @@ def build_set_orchestration_service_state_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. @@ -982,13 +990,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -997,9 +1008,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -1008,9 +1021,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1047,17 +1062,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -1069,11 +1087,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1103,9 +1123,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1128,37 +1148,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1175,17 +1205,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -1197,11 +1230,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1227,9 +1262,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1252,37 +1287,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1302,13 +1347,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1318,11 +1366,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1368,21 +1418,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1392,8 +1447,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1412,7 +1473,7 @@ def get( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1424,13 +1485,16 @@ def get( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1439,11 +1503,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1468,17 +1534,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1493,11 +1562,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1519,7 +1590,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1546,23 +1617,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1572,8 +1648,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1590,18 +1672,21 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1614,11 +1699,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements json=_json, force_deletion=force_deletion, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1640,7 +1727,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: @@ -1668,17 +1755,20 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, @@ -1686,6 +1776,8 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1695,8 +1787,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1715,7 +1813,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1727,13 +1825,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1742,11 +1843,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1772,7 +1875,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1784,13 +1887,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1799,9 +1905,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1810,9 +1918,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1849,7 +1959,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1861,13 +1971,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1875,9 +1988,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1885,9 +2000,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1926,7 +2043,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1941,13 +2058,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1957,9 +2077,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1969,9 +2091,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2010,7 +2134,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -2024,13 +2148,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2040,9 +2167,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2052,9 +2181,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2092,17 +2223,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2118,11 +2252,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2145,7 +2281,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -2176,17 +2312,20 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -2194,6 +2333,8 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2203,8 +2344,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2221,17 +2368,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2246,11 +2396,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2272,7 +2424,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2297,23 +2449,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2323,8 +2480,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2341,17 +2504,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2366,11 +2532,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2392,7 +2560,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2417,23 +2585,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2443,8 +2616,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2461,17 +2640,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2486,11 +2668,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2512,7 +2696,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2538,23 +2722,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2564,8 +2753,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2582,17 +2777,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2607,11 +2805,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2633,7 +2833,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2661,23 +2861,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2687,8 +2892,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2705,17 +2916,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2727,11 +2941,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2753,7 +2969,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2777,23 +2993,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[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._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2803,8 +3024,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2821,17 +3048,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -2846,11 +3076,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2872,7 +3104,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -2898,23 +3130,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2924,8 +3161,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2942,17 +3185,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2967,11 +3213,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2993,7 +3241,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -3019,23 +3267,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -3045,8 +3298,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -3066,7 +3325,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -3082,13 +3341,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2020_12_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -3098,11 +3360,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3128,7 +3392,7 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -3145,14 +3409,17 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st :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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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[None] _json = self._serialize.body(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -3164,11 +3431,13 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3189,17 +3458,20 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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[None] _json = self._serialize.body(parameters, 'OrchestrationServiceStateInput') @@ -3211,11 +3483,13 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3237,7 +3511,7 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> LROPoller[None]: """Changes ServiceState property for a given service. @@ -3260,23 +3534,28 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[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._set_orchestration_service_state_initial( + raw_result = self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -3286,8 +3565,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_sizes_operations.py index 2395451b8735..05897d47ee44 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -99,13 +99,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machines_operations.py index 2e6eacc166e0..fde04bf12744 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2020_12_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -203,8 +207,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -216,15 +221,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -237,9 +241,12 @@ def build_get_request( expand: Optional[str] = "instanceView", **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -251,20 +258,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -275,9 +280,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -289,18 +297,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -311,8 +317,9 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -324,13 +331,12 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -341,8 +347,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -354,13 +361,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -371,8 +377,9 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -384,13 +391,12 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -400,9 +406,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -413,18 +422,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -435,9 +442,12 @@ def build_list_all_request( status_only: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -447,20 +457,18 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 status_only is not None: - _query_parameters['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') + _params['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -471,9 +479,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -485,18 +496,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -509,8 +518,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -522,15 +532,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -541,9 +550,12 @@ def build_reapply_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply") # pylint: disable=line-too-long path_format_arguments = { @@ -555,18 +567,16 @@ def build_reapply_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -577,8 +587,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -590,13 +601,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -607,8 +617,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -620,13 +631,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -637,8 +647,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -650,13 +661,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -666,13 +676,15 @@ def build_reimage_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -684,19 +696,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -711,9 +721,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -725,20 +738,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -749,8 +760,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -762,13 +774,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -779,8 +790,9 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -792,13 +804,12 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -809,9 +820,12 @@ def build_assess_patches_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = case_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-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -823,18 +837,16 @@ def build_assess_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -844,14 +856,17 @@ def build_install_patches_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineInstallPatchesParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -863,20 +878,18 @@ def build_install_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -888,14 +901,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_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-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -907,53 +923,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2020_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.compute.v2020_12_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -965,13 +977,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -980,9 +995,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -991,9 +1008,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1030,17 +1049,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -1052,11 +1074,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1084,9 +1108,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -1110,37 +1134,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -1157,17 +1191,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -1179,11 +1216,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1213,9 +1252,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -1238,37 +1277,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1285,17 +1334,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1307,11 +1359,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1337,9 +1391,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1361,37 +1415,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1411,13 +1475,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1427,11 +1494,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1477,21 +1546,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1501,8 +1575,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1522,28 +1602,31 @@ def get( vm_name: str, expand: Optional[str] = "instanceView", **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str - :param expand: The expand expression to apply on the operation. Possible values are - "instanceView" or None. Default value is "instanceView". + :param expand: The expand expression to apply on the operation. Known values are "instanceView" + or None. Default value is "instanceView". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachine, or the result of cls(response) :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1553,11 +1636,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1584,7 +1669,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1596,13 +1681,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2020_12_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1611,11 +1699,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1642,13 +1732,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1657,11 +1750,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1704,20 +1799,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1727,8 +1827,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1747,13 +1853,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -1762,11 +1871,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1809,20 +1920,25 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1832,8 +1948,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1869,13 +1991,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1884,11 +2009,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1910,7 +2037,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1923,13 +2050,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1938,9 +2068,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1949,9 +2081,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1989,7 +2123,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -2003,13 +2137,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2018,9 +2155,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2029,9 +2168,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2070,7 +2211,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -2085,13 +2226,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2101,9 +2245,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2113,9 +2259,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2155,13 +2303,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -2171,11 +2322,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2223,21 +2376,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2247,8 +2405,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2267,13 +2431,16 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -2282,11 +2449,13 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2328,20 +2497,25 @@ def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._reapply_initial( + raw_result = self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2351,8 +2525,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2371,13 +2551,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2386,11 +2569,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2432,20 +2617,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2455,8 +2645,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2475,13 +2671,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2490,11 +2689,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2536,20 +2737,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2559,8 +2765,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2579,13 +2791,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2594,11 +2809,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2640,20 +2857,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2663,8 +2885,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2681,17 +2909,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -2706,11 +2937,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2732,7 +2965,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -2756,23 +2989,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_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-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[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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -2782,8 +3020,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2803,7 +3047,7 @@ def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -2819,13 +3063,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2020_12_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -2835,11 +3082,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2866,13 +3115,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2881,11 +3133,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2927,20 +3181,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2950,8 +3209,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2982,13 +3247,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2997,11 +3265,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3023,14 +3293,17 @@ def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -3039,11 +3312,13 @@ def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3072,7 +3347,7 @@ def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -3093,34 +3368,44 @@ def begin_assess_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -3137,17 +3422,20 @@ def _install_patches_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineInstallPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineInstallPatchesResult"]] + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-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.VirtualMachineInstallPatchesResult]] _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') @@ -3159,11 +3447,13 @@ def _install_patches_initial( content_type=content_type, json=_json, template_url=self._install_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3191,9 +3481,9 @@ def begin_install_patches( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineInstallPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. @@ -3217,37 +3507,47 @@ def begin_install_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.VirtualMachineInstallPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_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-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.VirtualMachineInstallPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstallPatchesResult"] 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._install_patches_initial( + raw_result = self._install_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineInstallPatchesResult', 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( @@ -3264,18 +3564,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -3287,11 +3590,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3319,11 +3624,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -3332,7 +3637,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2020_12_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -3348,36 +3653,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2020_12_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/_compute_management_client.py index a34d3b4a48e1..b51f0fe14d40 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/_compute_management_client.py @@ -135,35 +135,93 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.cloud_service_role_instances = CloudServiceRoleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_service_roles = CloudServiceRolesOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_services = CloudServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_services_update_domain = CloudServicesUpdateDomainOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_service_operating_systems = CloudServiceOperatingSystemsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_point_collections = RestorePointCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.cloud_service_role_instances = CloudServiceRoleInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_roles = CloudServiceRolesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services = CloudServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services_update_domain = CloudServicesUpdateDomainOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_operating_systems = CloudServiceOperatingSystemsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_point_collections = RestorePointCollectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_points = RestorePointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/_compute_management_client.py index 55e84cc12759..f5d32ebd537d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/_compute_management_client.py @@ -137,35 +137,93 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.cloud_service_role_instances = CloudServiceRoleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_service_roles = CloudServiceRolesOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_services = CloudServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_services_update_domain = CloudServicesUpdateDomainOperations(self._client, self._config, self._serialize, self._deserialize) - self.cloud_service_operating_systems = CloudServiceOperatingSystemsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_point_collections = RestorePointCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.cloud_service_role_instances = CloudServiceRoleInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_roles = CloudServiceRolesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services = CloudServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services_update_domain = CloudServicesUpdateDomainOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_operating_systems = CloudServiceOperatingSystemsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_point_collections = RestorePointCollectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_points = RestorePointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/__init__.py index 1e078da6ebf8..d6527d80373b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/__init__.py @@ -36,6 +36,9 @@ from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations from ._virtual_machine_scale_set_vm_run_commands_operations import VirtualMachineScaleSetVMRunCommandsOperations +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__ = [ 'CloudServiceRoleInstancesOperations', 'CloudServiceRolesOperations', @@ -67,3 +70,5 @@ 'VirtualMachineRunCommandsOperations', 'VirtualMachineScaleSetVMRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_availability_sets_operations.py index 0be8a1f301b9..fe03026d9ab7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_service_operating_systems_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_service_operating_systems_operations.py index 05b6857162fb..54a25b1e11f4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_service_operating_systems_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_service_operating_systems_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CloudServiceOperatingSystemsOperations: - """CloudServiceOperatingSystemsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`cloud_service_operating_systems` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_os_version( @@ -51,7 +50,7 @@ async def get_os_version( location: str, os_version_name: str, **kwargs: Any - ) -> "_models.OSVersion": + ) -> _models.OSVersion: """Gets properties of a guest operating system version that can be specified in the XML service configuration (.cscfg) for a cloud service. @@ -64,13 +63,16 @@ async def get_os_version( :rtype: ~azure.mgmt.compute.v2021_03_01.models.OSVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OSVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSVersion] request = build_get_os_version_request( @@ -79,11 +81,13 @@ async def get_os_version( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_version.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -109,7 +113,7 @@ def list_os_versions( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.OSVersionListResult"]: + ) -> AsyncIterable[_models.OSVersionListResult]: """Gets a list of all guest operating system versions available to be specified in the XML service configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the next page of OS versions. Do this till nextLink is null to fetch all the OS versions. @@ -122,13 +126,16 @@ def list_os_versions( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.OSVersionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSVersionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OSVersionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -137,9 +144,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_os_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -148,9 +157,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -189,7 +200,7 @@ async def get_os_family( location: str, os_family_name: str, **kwargs: Any - ) -> "_models.OSFamily": + ) -> _models.OSFamily: """Gets properties of a guest operating system family that can be specified in the XML service configuration (.cscfg) for a cloud service. @@ -202,13 +213,16 @@ async def get_os_family( :rtype: ~azure.mgmt.compute.v2021_03_01.models.OSFamily :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OSFamily"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSFamily] request = build_get_os_family_request( @@ -217,11 +231,13 @@ async def get_os_family( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_family.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,7 +263,7 @@ def list_os_families( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.OSFamilyListResult"]: + ) -> AsyncIterable[_models.OSFamilyListResult]: """Gets a list of all guest operating system families available to be specified in the XML service configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the next page of OS Families. Do this till nextLink is null to fetch all the OS Families. @@ -260,13 +276,16 @@ def list_os_families( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.OSFamilyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSFamilyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OSFamilyListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -275,9 +294,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_os_families.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -286,9 +307,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_service_role_instances_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_service_role_instances_operations.py index 30015f68aa70..646426571f9a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_service_role_instances_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_service_role_instances_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CloudServiceRoleInstancesOperations: - """CloudServiceRoleInstancesOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`cloud_service_role_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -54,13 +53,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements cloud_service_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -70,11 +72,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,21 +123,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -143,8 +152,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -165,7 +180,7 @@ async def get( cloud_service_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.RoleInstance": + ) -> _models.RoleInstance: """Gets a role instance from a cloud service. :param role_instance_name: Name of the role instance. @@ -182,13 +197,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RoleInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstance] request = build_get_request( @@ -199,11 +217,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -231,7 +251,7 @@ async def get_instance_view( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.RoleInstanceView": + ) -> _models.RoleInstanceView: """Retrieves information about the run-time state of a role instance in a cloud service. :param role_instance_name: Name of the role instance. @@ -245,13 +265,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RoleInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstanceView] request = build_get_instance_view_request( @@ -261,11 +284,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -293,7 +318,7 @@ def list( cloud_service_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.RoleInstanceListResult"]: + ) -> AsyncIterable[_models.RoleInstanceListResult]: """Gets the list of all role instances in a cloud service. Use nextLink property in the response to get the next page of role instances. Do this till nextLink is null to fetch all the role instances. @@ -312,13 +337,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.RoleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstanceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -329,9 +357,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -342,9 +372,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -384,13 +416,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements cloud_service_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -400,11 +435,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,21 +487,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -474,8 +516,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -495,13 +543,16 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements cloud_service_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_request_initial( @@ -511,11 +562,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -561,21 +614,26 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -585,8 +643,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -606,13 +670,16 @@ async def _rebuild_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_rebuild_request_initial( @@ -622,11 +689,13 @@ async def _rebuild_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._rebuild_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -673,21 +742,26 @@ async def begin_rebuild( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._rebuild_initial( + raw_result = await self._rebuild_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -697,8 +771,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -732,13 +812,16 @@ async def get_remote_desktop_file( :rtype: IO :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[IO] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[IO] request = build_get_remote_desktop_file_request( @@ -748,11 +831,13 @@ async def get_remote_desktop_file( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_remote_desktop_file.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=True, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_service_roles_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_service_roles_operations.py index ea71958333e8..0b06c20425ce 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_service_roles_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_service_roles_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CloudServiceRolesOperations: - """CloudServiceRolesOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`cloud_service_roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.CloudServiceRole": + ) -> _models.CloudServiceRole: """Gets a role from a cloud service. :param role_name: Name of the role. @@ -66,13 +65,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.CloudServiceRole :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceRole"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceRole] request = build_get_request( @@ -82,11 +84,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,7 +117,7 @@ def list( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CloudServiceRoleListResult"]: + ) -> AsyncIterable[_models.CloudServiceRoleListResult]: """Gets a list of all roles in a cloud service. Use nextLink property in the response to get the next page of roles. Do this till nextLink is null to fetch all the roles. @@ -128,13 +132,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.CloudServiceRoleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceRoleListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceRoleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -144,9 +151,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -156,9 +165,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_services_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_services_operations.py index 9fa8ccecb186..1d56d5d8c81c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_services_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_services_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CloudServicesOperations: # pylint: disable=too-many-public-methods - """CloudServicesOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`cloud_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") + async def _create_or_update_initial( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudService"] = None, + parameters: Optional[_models.CloudService] = None, **kwargs: Any - ) -> "_models.CloudService": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] + ) -> _models.CloudService: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] if parameters is not None: _json = self._serialize.body(parameters, 'CloudService') @@ -76,11 +78,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudService"] = None, + parameters: Optional[_models.CloudService] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.CloudService"]: + ) -> AsyncLROPoller[_models.CloudService]: """Create or update a cloud service. Please note some properties can be set only during cloud service creation. @@ -135,37 +139,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.CloudService] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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('CloudService', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudServiceUpdate"] = None, + parameters: Optional[_models.CloudServiceUpdate] = None, **kwargs: Any - ) -> "_models.CloudService": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] + ) -> _models.CloudService: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] if parameters is not None: _json = self._serialize.body(parameters, 'CloudServiceUpdate') @@ -207,11 +224,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -237,9 +256,9 @@ async def begin_update( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudServiceUpdate"] = None, + parameters: Optional[_models.CloudServiceUpdate] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.CloudService"]: + ) -> AsyncLROPoller[_models.CloudService]: """Update a cloud service. :param resource_group_name: Name of the resource group. @@ -261,37 +280,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.CloudService] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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('CloudService', 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( @@ -310,13 +339,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -325,11 +357,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,20 +405,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -394,8 +433,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -414,7 +459,7 @@ async def get( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.CloudService": + ) -> _models.CloudService: """Display information about a cloud service. :param resource_group_name: Name of the resource group. @@ -426,13 +471,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.CloudService :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] request = build_get_request( @@ -441,11 +489,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -472,7 +522,7 @@ async def get_instance_view( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.CloudServiceInstanceView": + ) -> _models.CloudServiceInstanceView: """Gets the status of a cloud service. :param resource_group_name: Name of the resource group. @@ -484,13 +534,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_03_01.models.CloudServiceInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceInstanceView] request = build_get_instance_view_request( @@ -499,11 +552,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -528,7 +583,7 @@ async def get_instance_view( def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.CloudServiceListResult"]: + ) -> AsyncIterable[_models.CloudServiceListResult]: """Gets a list of all cloud services in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud Services. @@ -540,13 +595,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.CloudServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +612,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -564,9 +624,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -604,7 +666,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CloudServiceListResult"]: + ) -> AsyncIterable[_models.CloudServiceListResult]: """Gets a list of all cloud services under a resource group. Use nextLink property in the response to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud Services. @@ -618,13 +680,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.CloudServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -633,9 +698,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -644,9 +711,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -685,13 +754,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -700,11 +772,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -746,20 +820,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -769,8 +848,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -789,13 +874,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -804,11 +892,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -851,20 +941,25 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -874,8 +969,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -892,17 +993,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -917,11 +1021,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -943,7 +1049,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more role instances in a cloud service. @@ -966,23 +1072,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -992,8 +1103,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1010,17 +1127,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1035,11 +1155,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1061,7 +1183,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimage asynchronous operation reinstalls the operating system on instances of web roles or @@ -1085,23 +1207,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1111,8 +1238,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1129,17 +1262,20 @@ async def _rebuild_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1154,11 +1290,13 @@ async def _rebuild_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._rebuild_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1180,7 +1318,7 @@ async def begin_rebuild( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker @@ -1205,23 +1343,28 @@ async def begin_rebuild( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._rebuild_initial( + raw_result = await self._rebuild_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1231,8 +1374,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1249,17 +1398,20 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1274,11 +1426,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1300,7 +1454,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes role instances in a cloud service. @@ -1323,23 +1477,28 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1349,8 +1508,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_services_update_domain_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_services_update_domain_operations.py index afb1c23fc97c..5a78d8bbb9e5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_services_update_domain_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_cloud_services_update_domain_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CloudServicesUpdateDomainOperations: - """CloudServicesUpdateDomainOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`cloud_services_update_domain` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _walk_update_domain_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, update_domain: int, - parameters: Optional["_models.UpdateDomain"] = None, + parameters: Optional[_models.UpdateDomain] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'UpdateDomain') @@ -78,11 +80,13 @@ async def _walk_update_domain_initial( # pylint: disable=inconsistent-return-st content_type=content_type, json=_json, template_url=self._walk_update_domain_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_walk_update_domain( # pylint: disable=inconsistent-return-state resource_group_name: str, cloud_service_name: str, update_domain: int, - parameters: Optional["_models.UpdateDomain"] = None, + parameters: Optional[_models.UpdateDomain] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Updates the role instances in the specified update domain. @@ -132,17 +136,20 @@ async def begin_walk_update_domain( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._walk_update_domain_initial( + raw_result = await self._walk_update_domain_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, update_domain=update_domain, @@ -150,6 +157,8 @@ async def begin_walk_update_domain( # pylint: disable=inconsistent-return-state api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,7 +195,7 @@ async def get_update_domain( cloud_service_name: str, update_domain: int, **kwargs: Any - ) -> "_models.UpdateDomain": + ) -> _models.UpdateDomain: """Gets the specified update domain of a cloud service. Use nextLink property in the response to get the next page of update domains. Do this till nextLink is null to fetch all the update domains. @@ -198,13 +213,16 @@ async def get_update_domain( :rtype: ~azure.mgmt.compute.v2021_03_01.models.UpdateDomain :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateDomain"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateDomain] request = build_get_update_domain_request( @@ -214,11 +232,13 @@ async def get_update_domain( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_update_domain.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -245,7 +265,7 @@ def list_update_domains( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> AsyncIterable["_models.UpdateDomainListResult"]: + ) -> AsyncIterable[_models.UpdateDomainListResult]: """Gets a list of all update domains in a cloud service. :param resource_group_name: Name of the resource group. @@ -259,13 +279,16 @@ def list_update_domains( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.UpdateDomainListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateDomainListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateDomainListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -275,9 +298,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_update_domains.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -287,9 +312,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_dedicated_host_groups_operations.py index 69b31cfad687..9f3f0674e354 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_dedicated_host_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostGroupsOperations: - """DedicatedHostGroupsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -137,14 +141,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -156,11 +163,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -199,13 +208,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,11 +226,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +256,7 @@ async def get( host_group_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -258,13 +272,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -274,11 +291,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +323,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -317,13 +336,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -332,9 +354,11 @@ def prepare_request(next_link=None): 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: @@ -343,9 +367,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -382,7 +408,7 @@ async def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -393,13 +419,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -407,9 +436,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -417,9 +448,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_dedicated_hosts_operations.py index ee84e6c41f4e..ef2626499b7a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostsOperations: - """DedicatedHostsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('DedicatedHost', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -267,17 +286,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -285,20 +307,27 @@ async def begin_update( 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('DedicatedHost', 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( @@ -318,13 +347,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -334,11 +366,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,21 +417,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -407,8 +446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -429,7 +474,7 @@ async def get( host_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -495,7 +545,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostListResult"]: + ) -> AsyncIterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -510,13 +560,16 @@ def list_by_host_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -526,9 +579,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -538,9 +593,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_images_operations.py index 747d5c3c6178..17968433b425 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_log_analytics_operations.py index 28e02943ffc8..82f568ed1e9e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_operations.py index 0decfff1635a..99ad19ce305f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_proximity_placement_groups_operations.py index 32df9b20d4e2..7c0061243efa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,7 +254,7 @@ async def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -255,13 +269,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -271,11 +288,13 @@ async def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -300,7 +319,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -310,13 +329,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -324,9 +346,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -334,9 +358,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -374,7 +400,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -386,13 +412,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,9 +430,11 @@ def prepare_request(next_link=None): 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: @@ -412,9 +443,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_restore_point_collections_operations.py index 9ea017ad93fc..aa42cb87eee6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_restore_point_collections_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_restore_point_collections_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,35 +27,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RestorePointCollectionsOperations: - """RestorePointCollectionsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollection", + parameters: _models.RestorePointCollection, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. @@ -71,14 +70,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollection') @@ -90,11 +92,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -125,9 +129,9 @@ async def update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollectionUpdate", + parameters: _models.RestorePointCollectionUpdate, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. @@ -141,14 +145,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollectionUpdate') @@ -160,11 +167,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -192,13 +201,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -207,11 +219,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_name=restore_point_collection_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -254,20 +268,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -277,8 +296,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -298,7 +323,7 @@ async def get( restore_point_collection_name: str, expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to get the restore point collection. :param resource_group_name: The name of the resource group. @@ -313,13 +338,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] request = build_get_request( @@ -329,11 +357,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -360,7 +390,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.RestorePointCollectionListResult"]: + ) -> AsyncIterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in a resource group. :param resource_group_name: The name of the resource group. @@ -372,13 +402,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -387,9 +420,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -398,9 +433,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -438,7 +475,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.RestorePointCollectionListResult"]: + ) -> AsyncIterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in the subscription. Use nextLink property in the response to get the next page of restore point collections. Do this till nextLink is not null to fetch all the restore point collections. @@ -450,13 +487,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -464,9 +504,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -474,9 +516,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_restore_points_operations.py index b52a1fc27dcf..eb652bd95884 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_restore_points_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_restore_points_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RestorePointsOperations: - """RestorePointsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`restore_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_initial( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> "_models.RestorePoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] + ) -> _models.RestorePoint: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] _json = self._serialize.body(parameters, 'RestorePoint') @@ -73,11 +75,13 @@ async def _create_initial( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -104,9 +108,9 @@ async def begin_create( resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> AsyncLROPoller["_models.RestorePoint"]: + ) -> AsyncLROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. @@ -131,17 +135,20 @@ async def begin_create( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.RestorePoint] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] 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, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, @@ -149,20 +156,27 @@ async def begin_create( 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('RestorePoint', 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( @@ -182,13 +196,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -198,11 +215,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_name=restore_point_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,21 +266,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -271,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -292,7 +322,7 @@ async def get( restore_point_collection_name: str, restore_point_name: str, **kwargs: Any - ) -> "_models.RestorePoint": + ) -> _models.RestorePoint: """The operation to get the restore point. :param resource_group_name: The name of the resource group. @@ -306,13 +336,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] request = build_get_request( @@ -322,11 +355,13 @@ async def get( restore_point_name=restore_point_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_ssh_public_keys_operations.py index 1c61740c9fa5..0f2941f8b683 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_ssh_public_keys_operations.py @@ -15,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 @@ -24,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SshPublicKeysOperations: - """SshPublicKeysOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -60,13 +59,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -74,9 +76,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -84,9 +88,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +130,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -137,13 +143,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -152,9 +161,11 @@ def prepare_request(next_link=None): 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: @@ -163,9 +174,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -203,9 +216,9 @@ async def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -219,14 +232,17 @@ async def create( :rtype: ~azure.mgmt.compute.v2021_03_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -238,11 +254,13 @@ async def create( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -272,9 +290,9 @@ async def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -288,14 +306,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -307,11 +328,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -350,13 +373,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -365,11 +391,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,7 +420,7 @@ async def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -404,13 +432,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -419,11 +450,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,7 +483,7 @@ async def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -464,13 +497,16 @@ async def generate_key_pair( :rtype: ~azure.mgmt.compute.v2021_03_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -479,11 +515,13 @@ async def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_usage_operations.py index 5f6f48451b86..b9f9ec790a40 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_extension_images_operations.py index 39736df6dfdf..d6c7c9e4d6c9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_extensions_operations.py index e3fa1c8bad99..74cde3ad818f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_images_edge_zone_operations.py index 6f0ee1f73379..4a78f752093c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_images_edge_zone_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesEdgeZoneOperations: - """VirtualMachineImagesEdgeZoneOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +52,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. @@ -73,13 +72,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -92,11 +94,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -130,7 +134,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. @@ -157,13 +161,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -178,11 +185,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -211,7 +220,7 @@ async def list_offers( edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. @@ -226,13 +235,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -242,11 +254,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -274,7 +288,7 @@ async def list_publishers( location: str, edge_zone: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. @@ -286,13 +300,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -301,11 +318,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -335,7 +354,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. @@ -352,13 +371,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -369,11 +391,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_images_operations.py index 8c7dd21a3b3b..dddf521ade0d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_run_commands_operations.py index abdb68437c8c..b0de6fee3ce4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -64,13 +63,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,7 +137,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -143,13 +149,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -158,11 +167,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,18 +199,21 @@ async def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -212,11 +226,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,11 +263,11 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -263,7 +279,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -280,16 +296,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -297,20 +316,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -328,18 +354,21 @@ async def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -352,11 +381,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,11 +414,11 @@ async def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -398,7 +429,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -415,16 +446,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -432,20 +466,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -465,13 +506,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -481,11 +525,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,21 +576,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -554,8 +605,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -576,7 +633,7 @@ async def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -592,13 +649,16 @@ async def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -609,11 +669,13 @@ async def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -642,7 +704,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -658,13 +720,16 @@ def list_by_virtual_machine( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -675,9 +740,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -688,9 +755,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index 24042867f37f..f6756586e9e2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -189,17 +203,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -212,11 +229,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -276,17 +295,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -294,20 +316,27 @@ async def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -327,13 +356,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -343,11 +375,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,21 +426,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -416,8 +455,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -438,7 +483,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -516,13 +566,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -532,9 +585,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -544,9 +599,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index c2a10e072c88..1865168bf3b6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,13 +292,16 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu vm_scale_set_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -276,11 +310,13 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,20 +360,25 @@ async def begin_start_extension_upgrade( # pylint: disable=inconsistent-return- :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_extension_upgrade_initial( + raw_result = await self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -347,8 +388,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -367,7 +414,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -379,13 +426,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -394,11 +444,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py index acdcabd46e83..a6272f39f2f2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMExtensionsOperations: - """VirtualMachineScaleSetVMExtensionsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -51,17 +50,20 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -111,9 +115,9 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -161,20 +168,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -193,17 +207,20 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -217,11 +234,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -249,9 +268,9 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -280,17 +299,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -299,20 +321,27 @@ async def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -333,13 +362,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -350,11 +382,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -402,22 +436,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -427,8 +466,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -450,7 +495,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -468,13 +513,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -486,11 +534,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -520,7 +570,7 @@ async def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -536,13 +586,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -553,11 +606,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index daebd14fe124..20cd75a6e4eb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMRunCommandsOperations: - """VirtualMachineScaleSetVMRunCommandsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,18 +52,21 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -78,11 +80,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -114,11 +118,11 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -131,7 +135,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -148,16 +152,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -166,20 +173,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -198,18 +212,21 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -223,11 +240,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,11 +274,11 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -272,7 +291,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -289,16 +308,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -307,20 +329,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -341,13 +370,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -358,11 +390,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -410,22 +444,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -435,8 +474,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -458,7 +503,7 @@ async def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -476,13 +521,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_request( @@ -494,11 +542,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -528,7 +578,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -546,13 +596,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -564,9 +617,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -578,9 +633,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index 55709e3c7d05..72a90b7e96aa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -78,11 +80,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -132,17 +136,20 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -150,6 +157,8 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,13 +195,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -196,11 +214,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,21 +266,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -270,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -291,13 +322,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -307,11 +341,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,21 +394,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -382,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -401,17 +448,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -424,11 +474,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,9 +511,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -487,17 +539,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -505,20 +560,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -539,13 +601,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -556,11 +621,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -609,22 +676,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -634,8 +706,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -656,7 +734,7 @@ async def get( instance_id: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -674,13 +752,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -691,11 +772,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -723,7 +806,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -737,13 +820,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -753,11 +839,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -787,7 +875,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -811,13 +899,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -830,9 +921,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -845,9 +938,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -888,13 +983,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -905,11 +1003,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -961,22 +1061,27 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -986,8 +1091,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1007,13 +1118,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1023,11 +1137,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1072,21 +1188,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1096,8 +1217,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1117,13 +1244,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1133,11 +1263,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1182,21 +1314,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1206,8 +1343,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1227,13 +1370,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1243,11 +1389,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1293,21 +1441,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1317,8 +1470,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1339,7 +1498,7 @@ async def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -1358,13 +1517,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1375,11 +1537,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1408,13 +1572,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1424,11 +1591,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1473,21 +1642,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1497,8 +1671,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1532,13 +1712,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -1548,11 +1731,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1574,18 +1759,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1598,11 +1786,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1631,11 +1821,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1646,7 +1836,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_03_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1663,16 +1853,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1680,20 +1873,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_sets_operations.py index 5dd2e42fdd82..b3231a1b2fa9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -130,17 +136,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -152,11 +161,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -186,9 +197,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -211,37 +222,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -258,17 +279,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -280,11 +304,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -310,9 +336,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -335,37 +361,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -385,13 +421,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -401,11 +440,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -451,21 +492,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -475,8 +521,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -496,7 +548,7 @@ async def get( vm_scale_set_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -512,13 +564,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -528,11 +583,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -557,17 +614,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -582,11 +642,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -608,7 +670,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -635,23 +697,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -661,8 +728,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -679,18 +752,21 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -703,11 +779,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat json=_json, force_deletion=force_deletion, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,7 +807,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: @@ -757,17 +835,20 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, @@ -775,6 +856,8 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -784,8 +867,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -804,7 +893,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -816,13 +905,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -831,11 +923,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -861,7 +955,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -873,13 +967,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -888,9 +985,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -899,9 +998,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -938,7 +1039,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -950,13 +1051,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -964,9 +1068,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -974,9 +1080,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1015,7 +1123,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1030,13 +1138,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1046,9 +1157,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1058,9 +1171,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1099,7 +1214,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1113,13 +1228,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1129,9 +1247,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1141,9 +1261,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1181,17 +1303,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1207,11 +1332,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1234,7 +1361,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1265,17 +1392,20 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -1283,6 +1413,8 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1292,8 +1424,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1310,17 +1448,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1335,11 +1476,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1361,7 +1504,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1386,23 +1529,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1412,8 +1560,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1430,17 +1584,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1455,11 +1612,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1481,7 +1640,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1506,23 +1665,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1532,8 +1696,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1550,17 +1720,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1575,11 +1748,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1601,7 +1776,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1627,23 +1802,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1653,8 +1833,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1671,17 +1857,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1696,11 +1885,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1722,7 +1913,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1750,23 +1941,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1776,8 +1972,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1794,17 +1996,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1816,11 +2021,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1842,7 +2049,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1866,23 +2073,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1892,8 +2104,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1910,17 +2128,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -1935,11 +2156,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1961,7 +2184,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -1987,23 +2210,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2013,8 +2241,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2031,17 +2265,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2056,11 +2293,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2082,7 +2321,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2108,23 +2347,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2134,8 +2378,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2155,7 +2405,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2171,13 +2421,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2187,11 +2440,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2217,7 +2472,7 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -2234,14 +2489,17 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret :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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -2253,11 +2511,13 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2278,17 +2538,20 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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(parameters, 'OrchestrationServiceStateInput') @@ -2300,11 +2563,13 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2326,7 +2591,7 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> AsyncLROPoller[None]: """Changes ServiceState property for a given service. @@ -2349,23 +2614,28 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._set_orchestration_service_state_initial( + raw_result = await self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -2375,8 +2645,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_sizes_operations.py index 325b408a0cf0..14593f068119 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machines_operations.py index 9608eb21e785..5cdf7f353367 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -338,37 +364,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -385,17 +421,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -407,11 +446,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -437,9 +478,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -462,37 +503,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -512,13 +563,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -528,11 +582,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -578,21 +634,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -602,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -623,7 +690,7 @@ async def get( vm_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. @@ -641,13 +708,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -657,11 +727,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -688,7 +760,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -700,13 +772,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -715,11 +790,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -746,13 +823,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -761,11 +841,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -808,20 +890,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -831,8 +918,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -851,13 +944,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -866,11 +962,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -913,20 +1011,25 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -936,8 +1039,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -973,13 +1082,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -988,11 +1100,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1014,7 +1128,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1027,13 +1141,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1042,9 +1159,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1053,9 +1172,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1093,7 +1214,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1107,13 +1228,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1122,9 +1246,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1133,9 +1259,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1174,7 +1302,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1189,13 +1317,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1205,9 +1336,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1217,9 +1350,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1259,13 +1394,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1275,11 +1413,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1327,21 +1467,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1351,8 +1496,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1371,13 +1522,16 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -1386,11 +1540,13 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1432,20 +1588,25 @@ async def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._reapply_initial( + raw_result = await self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1455,8 +1616,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1475,13 +1642,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1490,11 +1660,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1536,20 +1708,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1559,8 +1736,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1579,13 +1762,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1594,11 +1780,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1640,20 +1828,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1663,8 +1856,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1683,13 +1882,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1698,11 +1900,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1744,20 +1948,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1767,8 +1976,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1785,17 +2000,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -1810,11 +2028,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1836,7 +2056,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -1860,23 +2080,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -1886,8 +2111,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1907,7 +2138,7 @@ async def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -1923,13 +2154,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1939,11 +2173,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1971,13 +2207,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1986,11 +2225,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2032,20 +2273,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2055,8 +2301,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2087,13 +2339,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2102,11 +2357,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2128,14 +2385,17 @@ async def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -2144,11 +2404,13 @@ async def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2177,7 +2439,7 @@ async def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -2198,34 +2460,44 @@ async def begin_assess_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = await self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -2242,17 +2514,20 @@ async def _install_patches_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineInstallPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineInstallPatchesResult"]] + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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.VirtualMachineInstallPatchesResult]] _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') @@ -2264,11 +2539,13 @@ async def _install_patches_initial( content_type=content_type, json=_json, template_url=self._install_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2296,9 +2573,9 @@ async def begin_install_patches( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineInstallPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. @@ -2322,37 +2599,47 @@ async def begin_install_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineInstallPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstallPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstallPatchesResult"] 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._install_patches_initial( + raw_result = await self._install_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineInstallPatchesResult', 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( @@ -2369,18 +2656,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2392,11 +2682,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2424,11 +2716,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2437,7 +2729,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_03_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2454,36 +2746,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_03_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/__init__.py index 9dbb5c723c61..8dffce655750 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/__init__.py @@ -341,7 +341,9 @@ WindowsPatchAssessmentMode, WindowsVMGuestPatchMode, ) - +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__ = [ 'AdditionalCapabilities', 'AdditionalUnattendContent', @@ -675,3 +677,5 @@ 'WindowsPatchAssessmentMode', 'WindowsVMGuestPatchMode', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/_compute_management_client_enums.py index 9d628f8ac2d9..71582b965175 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. """ @@ -19,7 +18,7 @@ class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CLASSIC = "Classic" ALIGNED = "Aligned" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -30,7 +29,7 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class CloudServiceUpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CloudServiceUpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Update mode for the cloud service. Role instances are allocated to update domains when the service is deployed. Updates can be initiated manually in each update domain or initiated automatically in all update domains. @@ -45,7 +44,7 @@ class CloudServiceUpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) MANUAL = "Manual" SIMULTANEOUS = "Simultaneous" -class ConsistencyModeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConsistencyModeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the consistency mode for the restore point. Please refer to https://aka.ms/RestorePoints for more details. """ @@ -54,7 +53,7 @@ class ConsistencyModeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_SYSTEM_CONSISTENT = "FileSystemConsistent" APPLICATION_CONSISTENT = "ApplicationConsistent" -class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the software license type that will be applied to the VMs deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` @@ -65,20 +64,20 @@ class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" -class DeleteOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DeleteOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify what happens to the network interface when the VM is deleted """ DELETE = "Delete" DETACH = "Detach" -class DiffDiskOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk option for operating system disk. """ LOCAL = "Local" -class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskPlacement(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk placement for operating system disk. This property can be used by user in the request to choose the location i.e, cache disk or resource disk space for Ephemeral OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer @@ -91,7 +90,7 @@ class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CACHE_DISK = "CacheDisk" RESOURCE_DISK = "ResourceDisk" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -104,7 +103,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class DiskDeleteOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskDeleteOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the behavior of the managed disk when the VM gets deleted i.e whether the managed disk is deleted or detached. Supported values::code:`
`:code:`
` **Delete** If this value is used, the managed disk is deleted when VM gets deleted.:code:`
`:code:`
` **Detach** @@ -115,7 +114,7 @@ class DiskDeleteOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DELETE = "Delete" DETACH = "Detach" -class DiskDetachOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskDetachOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the detach behavior to be used while detaching a disk or which is already in the process of detachment from the virtual machine. Supported values: **ForceDetach**. :code:`
`:code:`
` detachOption: **ForceDetach** is applicable only for managed data @@ -129,7 +128,7 @@ class DiskDetachOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FORCE_DETACH = "ForceDetach" -class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExecutionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Script execution status. """ @@ -141,36 +140,36 @@ class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TIMED_OUT = "TimedOut" CANCELED = "Canceled" -class ExpandTypesForGetVMScaleSets(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpandTypesForGetVMScaleSets(str, Enum, metaclass=CaseInsensitiveEnumMeta): USER_DATA = "userData" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class HyperVGenerationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type associated with a resource """ V1 = "V1" V2 = "V2" -class HyperVGenerationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type """ V1 = "V1" V2 = "V2" -class InstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" USER_DATA = "userData" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -179,7 +178,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -188,7 +187,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class IPVersions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -197,7 +196,7 @@ class IPVersions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class LinuxPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinuxPatchAssessmentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` @@ -208,7 +207,7 @@ class LinuxPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class LinuxVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinuxVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's @@ -220,7 +219,7 @@ class LinuxVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -229,14 +228,14 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class NetworkApiVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations """ TWO_THOUSAND_TWENTY11_01 = "2020-11-01" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ @@ -245,34 +244,34 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: Specialized image. Contains already provisioned OS Disk. SPECIALIZED = "Specialized" -class OperatingSystemType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class OrchestrationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the orchestration mode for the virtual machine scale set. """ UNIFORM = "Uniform" FLEXIBLE = "Flexible" -class OrchestrationServiceNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the service. """ AUTOMATIC_REPAIRS = "AutomaticRepairs" -class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current state of the service. """ @@ -280,21 +279,21 @@ class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enu RUNNING = "Running" SUSPENDED = "Suspended" -class OrchestrationServiceStateAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceStateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The action to be performed. """ RESUME = "Resume" SUSPEND = "Suspend" -class PatchAssessmentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchAssessmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the availability of a given patch. """ UNKNOWN = "Unknown" AVAILABLE = "Available" -class PatchInstallationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchInstallationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the patch after the installation operation completed. """ @@ -305,7 +304,7 @@ class PatchInstallationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) NOT_SELECTED = "NotSelected" PENDING = "Pending" -class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", or "CompletedWithWarnings." @@ -317,7 +316,7 @@ class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -325,7 +324,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -334,28 +333,28 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class PublicIPAddressSkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAddressSkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify public IP sku name """ BASIC = "Basic" STANDARD = "Standard" -class PublicIPAddressSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAddressSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify public IP sku tier """ REGIONAL = "Regional" GLOBAL_ENUM = "Global" -class PublicIPAllocationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify the public IP allocation type """ DYNAMIC = "Dynamic" STATIC = "Static" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -366,18 +365,18 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RestorePointCollectionExpandOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RestorePointCollectionExpandOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): RESTORE_POINTS = "restorePoints" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -386,7 +385,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not be enabled unless this property is set as TrustedLaunch. @@ -394,7 +393,7 @@ class SecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TRUSTED_LAUNCH = "TrustedLaunch" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -402,7 +401,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -410,7 +409,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. StandardSSD_LRS uses Standard SSD. Premium_LRS uses Premium SSD. UltraSSD_LRS uses Ultra disk. @@ -427,7 +426,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PREMIUM_ZRS = "Premium_ZRS" STANDARD_SSD_ZRS = "StandardSSD_ZRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -439,7 +438,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -447,7 +446,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -456,14 +455,14 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for the Azure Spot VM/VMSS """ DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for a standalone virtual machine or the virtual machines in the scale set. :code:`
`:code:`
` 'Low' enum will be deprecated in the future, please use 'Spot' as the enum to deploy Azure Spot VM/VMSS. @@ -473,20 +472,20 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E LOW = "Low" SPOT = "Spot" -class VirtualMachineScaleSetScaleInRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "Default" OLDEST_VM = "OldestVM" NEWEST_VM = "NewestVM" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. :code:`
`:code:`
` The enum data type is currently deprecated and will be removed by December 23rd 2023. :code:`
`:code:`
` Recommended way to get the list of available sizes is using these APIs: @@ -668,20 +667,20 @@ class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) STANDARD_NV12 = "Standard_NV12" STANDARD_NV24 = "Standard_NV24" -class VmDiskTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VmDiskTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """VM disk types which are disallowed. """ NONE = "None" UNMANAGED = "Unmanaged" -class VMGuestPatchClassificationLinux(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchClassificationLinux(str, Enum, metaclass=CaseInsensitiveEnumMeta): CRITICAL = "Critical" SECURITY = "Security" OTHER = "Other" -class VMGuestPatchClassificationWindows(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchClassificationWindows(str, Enum, metaclass=CaseInsensitiveEnumMeta): CRITICAL = "Critical" SECURITY = "Security" @@ -692,7 +691,7 @@ class VMGuestPatchClassificationWindows(with_metaclass(CaseInsensitiveEnumMeta, TOOLS = "Tools" UPDATES = "Updates" -class VMGuestPatchRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the reboot requirements of the patch. """ @@ -701,7 +700,7 @@ class VMGuestPatchRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, En ALWAYS_REQUIRES_REBOOT = "AlwaysRequiresReboot" CAN_REQUEST_REBOOT = "CanRequestReboot" -class VMGuestPatchRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines when it is acceptable to reboot a VM during a software update operation. """ @@ -709,7 +708,7 @@ class VMGuestPatchRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enu NEVER = "Never" ALWAYS = "Always" -class VMGuestPatchRebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reboot state of the VM following completion of the operation. """ @@ -720,7 +719,7 @@ class VMGuestPatchRebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" COMPLETED = "Completed" -class WindowsPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WindowsPatchAssessmentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest patch assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` @@ -731,7 +730,7 @@ class WindowsPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, En IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class WindowsVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WindowsVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/_models_py3.py index 78c4b70600b4..4e978bf9bce9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AdditionalCapabilities(msrest.serialization.Model): @@ -57,7 +59,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2021_03_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -78,7 +80,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -91,7 +93,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2021_03_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -159,8 +161,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, @@ -212,8 +214,8 @@ class ApiErrorAutoGenerated(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -265,8 +267,8 @@ class ApiErrorAutoGenerated2(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -568,11 +570,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -630,7 +632,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -712,11 +714,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -752,8 +754,8 @@ class AvailablePatchSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_03_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -954,7 +956,7 @@ class CloudErrorAutoGenerated(msrest.serialization.Model): def __init__( self, *, - error: Optional["ApiErrorAutoGenerated"] = None, + error: Optional["_models.ApiErrorAutoGenerated"] = None, **kwargs ): """ @@ -979,7 +981,7 @@ class CloudErrorAutoGenerated2(msrest.serialization.Model): def __init__( self, *, - error: Optional["ApiErrorAutoGenerated2"] = None, + error: Optional["_models.ApiErrorAutoGenerated2"] = None, **kwargs ): """ @@ -1032,7 +1034,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - properties: Optional["CloudServiceProperties"] = None, + properties: Optional["_models.CloudServiceProperties"] = None, **kwargs ): """ @@ -1066,7 +1068,7 @@ class CloudServiceExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["Extension"]] = None, + extensions: Optional[List["_models.Extension"]] = None, **kwargs ): """ @@ -1149,7 +1151,7 @@ def __init__( auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[str] = None, protected_settings: Optional[str] = None, - protected_settings_from_key_vault: Optional["CloudServiceVaultAndSecretReference"] = None, + protected_settings_from_key_vault: Optional["_models.CloudServiceVaultAndSecretReference"] = None, force_update_tag: Optional[str] = None, roles_applied_to: Optional[List[str]] = None, **kwargs @@ -1240,7 +1242,7 @@ class CloudServiceInstanceView(msrest.serialization.Model): def __init__( self, *, - role_instance: Optional["InstanceViewStatusesSummary"] = None, + role_instance: Optional["_models.InstanceViewStatusesSummary"] = None, **kwargs ): """ @@ -1277,7 +1279,7 @@ class CloudServiceListResult(msrest.serialization.Model): def __init__( self, *, - value: List["CloudService"], + value: List["_models.CloudService"], next_link: Optional[str] = None, **kwargs ): @@ -1315,8 +1317,8 @@ class CloudServiceNetworkProfile(msrest.serialization.Model): def __init__( self, *, - load_balancer_configurations: Optional[List["LoadBalancerConfiguration"]] = None, - swappable_cloud_service: Optional["SubResource"] = None, + load_balancer_configurations: Optional[List["_models.LoadBalancerConfiguration"]] = None, + swappable_cloud_service: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -1350,7 +1352,7 @@ class CloudServiceOsProfile(msrest.serialization.Model): def __init__( self, *, - secrets: Optional[List["CloudServiceVaultSecretGroup"]] = None, + secrets: Optional[List["_models.CloudServiceVaultSecretGroup"]] = None, **kwargs ): """ @@ -1397,7 +1399,7 @@ class CloudServiceProperties(msrest.serialization.Model): **Manual** :code:`
`:code:`
`\ **Simultaneous**\ :code:`
`:code:`
` If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called to apply the update. If set to Auto, the update is automatically applied to each update domain - in sequence. Possible values include: "Auto", "Manual", "Simultaneous". + in sequence. Known values are: "Auto", "Manual", "Simultaneous". :vartype upgrade_mode: str or ~azure.mgmt.compute.v2021_03_01.models.CloudServiceUpgradeMode :ivar role_profile: Describes the role profile for the cloud service. :vartype role_profile: ~azure.mgmt.compute.v2021_03_01.models.CloudServiceRoleProfile @@ -1441,11 +1443,11 @@ def __init__( configuration_url: Optional[str] = None, start_cloud_service: Optional[bool] = None, allow_model_override: Optional[bool] = None, - upgrade_mode: Optional[Union[str, "CloudServiceUpgradeMode"]] = None, - role_profile: Optional["CloudServiceRoleProfile"] = None, - os_profile: Optional["CloudServiceOsProfile"] = None, - network_profile: Optional["CloudServiceNetworkProfile"] = None, - extension_profile: Optional["CloudServiceExtensionProfile"] = None, + upgrade_mode: Optional[Union[str, "_models.CloudServiceUpgradeMode"]] = None, + role_profile: Optional["_models.CloudServiceRoleProfile"] = None, + os_profile: Optional["_models.CloudServiceOsProfile"] = None, + network_profile: Optional["_models.CloudServiceNetworkProfile"] = None, + extension_profile: Optional["_models.CloudServiceExtensionProfile"] = None, **kwargs ): """ @@ -1479,7 +1481,7 @@ def __init__( **Manual** :code:`
`:code:`
`\ **Simultaneous**\ :code:`
`:code:`
` If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called to apply the update. If set to Auto, the update is automatically applied to each update domain - in sequence. Possible values include: "Auto", "Manual", "Simultaneous". + in sequence. Known values are: "Auto", "Manual", "Simultaneous". :paramtype upgrade_mode: str or ~azure.mgmt.compute.v2021_03_01.models.CloudServiceUpgradeMode :keyword role_profile: Describes the role profile for the cloud service. :paramtype role_profile: ~azure.mgmt.compute.v2021_03_01.models.CloudServiceRoleProfile @@ -1544,8 +1546,8 @@ class CloudServiceRole(msrest.serialization.Model): def __init__( self, *, - sku: Optional["CloudServiceRoleSku"] = None, - properties: Optional["CloudServiceRoleProperties"] = None, + sku: Optional["_models.CloudServiceRoleSku"] = None, + properties: Optional["_models.CloudServiceRoleProperties"] = None, **kwargs ): """ @@ -1586,7 +1588,7 @@ class CloudServiceRoleListResult(msrest.serialization.Model): def __init__( self, *, - value: List["CloudServiceRole"], + value: List["_models.CloudServiceRole"], next_link: Optional[str] = None, **kwargs ): @@ -1615,7 +1617,7 @@ class CloudServiceRoleProfile(msrest.serialization.Model): def __init__( self, *, - roles: Optional[List["CloudServiceRoleProfileProperties"]] = None, + roles: Optional[List["_models.CloudServiceRoleProfileProperties"]] = None, **kwargs ): """ @@ -1645,7 +1647,7 @@ def __init__( self, *, name: Optional[str] = None, - sku: Optional["CloudServiceRoleSku"] = None, + sku: Optional["_models.CloudServiceRoleSku"] = None, **kwargs ): """ @@ -1773,7 +1775,7 @@ class CloudServiceVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, + source_vault: Optional["_models.SubResource"] = None, secret_url: Optional[str] = None, **kwargs ): @@ -1835,8 +1837,8 @@ class CloudServiceVaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["CloudServiceVaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.CloudServiceVaultCertificate"]] = None, **kwargs ): """ @@ -1954,8 +1956,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1966,7 +1967,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1993,14 +1994,14 @@ class DataDisk(msrest.serialization.Model): force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. :code:`
`:code:`
` This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data - disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Possible - values include: "ForceDetach". + disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Known values + are: "ForceDetach". :vartype detach_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskDetachOptionTypes :ivar delete_option: Specifies whether data disk should be deleted or detached upon VM deletion.:code:`
`:code:`
` Possible values: :code:`
`:code:`
` **Delete** If this value is used, the data disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the data disk is retained after VM is deleted.:code:`
`:code:`
` - The default value is set to **detach**. Possible values include: "Delete", "Detach". + The default value is set to **detach**. Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskDeleteOptionTypes """ @@ -2032,17 +2033,17 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, to_be_detached: Optional[bool] = None, - detach_option: Optional[Union[str, "DiskDetachOptionTypes"]] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + detach_option: Optional[Union[str, "_models.DiskDetachOptionTypes"]] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ @@ -2061,8 +2062,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -2073,7 +2073,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -2092,14 +2092,14 @@ def __init__( force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. :code:`
`:code:`
` This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data - disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Possible - values include: "ForceDetach". + disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Known values + are: "ForceDetach". :paramtype detach_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskDetachOptionTypes :keyword delete_option: Specifies whether data disk should be deleted or detached upon VM deletion.:code:`
`:code:`
` Possible values: :code:`
`:code:`
` **Delete** If this value is used, the data disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the data disk is retained after VM is deleted.:code:`
`:code:`
` - The default value is set to **detach**. Possible values include: "Delete", "Detach". + The default value is set to **detach**. Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskDeleteOptionTypes """ super(DataDisk, self).__init__(**kwargs) @@ -2181,7 +2181,7 @@ class DedicatedHost(Resource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2021_03_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -2226,11 +2226,11 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -2251,7 +2251,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2021_03_01.models.DedicatedHostLicenseTypes """ @@ -2317,7 +2317,7 @@ class DedicatedHostAvailableCapacity(msrest.serialization.Model): def __init__( self, *, - allocatable_v_ms: Optional[List["DedicatedHostAllocatableVM"]] = None, + allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs ): """ @@ -2439,7 +2439,7 @@ class DedicatedHostGroupInstanceView(msrest.serialization.Model): def __init__( self, *, - hosts: Optional[List["DedicatedHostInstanceViewWithName"]] = None, + hosts: Optional[List["_models.DedicatedHostInstanceViewWithName"]] = None, **kwargs ): """ @@ -2475,7 +2475,7 @@ class DedicatedHostGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHostGroup"], + value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs ): @@ -2593,8 +2593,8 @@ class DedicatedHostInstanceView(msrest.serialization.Model): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2642,8 +2642,8 @@ class DedicatedHostInstanceViewWithName(DedicatedHostInstanceView): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2681,7 +2681,7 @@ class DedicatedHostListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHost"], + value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs ): @@ -2718,7 +2718,7 @@ class DedicatedHostUpdate(UpdateResource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2021_03_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -2755,7 +2755,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -2771,7 +2771,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2021_03_01.models.DedicatedHostLicenseTypes """ @@ -2803,7 +2803,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -2820,8 +2820,8 @@ def __init__( class DiffDiskSettings(msrest.serialization.Model): """Describes the parameters of ephemeral disk settings that can be specified for operating system disk. :code:`
`:code:`
` NOTE: The ephemeral disk settings can only be specified for managed disk. - :ivar option: Specifies the ephemeral disk settings for operating system disk. Possible values - include: "Local". + :ivar option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :vartype option: str or ~azure.mgmt.compute.v2021_03_01.models.DiffDiskOptions :ivar placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -2830,7 +2830,7 @@ class DiffDiskSettings(msrest.serialization.Model): Refer to VM size documentation for Windows VM at https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Possible values include: "CacheDisk", "ResourceDisk". + cache disk. Known values are: "CacheDisk", "ResourceDisk". :vartype placement: str or ~azure.mgmt.compute.v2021_03_01.models.DiffDiskPlacement """ @@ -2842,13 +2842,13 @@ class DiffDiskSettings(msrest.serialization.Model): def __init__( self, *, - option: Optional[Union[str, "DiffDiskOptions"]] = None, - placement: Optional[Union[str, "DiffDiskPlacement"]] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, + placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, **kwargs ): """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. Possible - values include: "Local". + :keyword option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :paramtype option: str or ~azure.mgmt.compute.v2021_03_01.models.DiffDiskOptions :keyword placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -2857,7 +2857,7 @@ def __init__( Refer to VM size documentation for Windows VM at https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Possible values include: "CacheDisk", "ResourceDisk". + cache disk. Known values are: "CacheDisk", "ResourceDisk". :paramtype placement: str or ~azure.mgmt.compute.v2021_03_01.models.DiffDiskPlacement """ super(DiffDiskSettings, self).__init__(**kwargs) @@ -2868,8 +2868,7 @@ def __init__( class DisallowedConfiguration(msrest.serialization.Model): """Specifies the disallowed configuration for a virtual machine image. - :ivar vm_disk_type: VM disk types which are disallowed. Possible values include: "None", - "Unmanaged". + :ivar vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :vartype vm_disk_type: str or ~azure.mgmt.compute.v2021_03_01.models.VmDiskTypes """ @@ -2880,11 +2879,11 @@ class DisallowedConfiguration(msrest.serialization.Model): def __init__( self, *, - vm_disk_type: Optional[Union[str, "VmDiskTypes"]] = None, + vm_disk_type: Optional[Union[str, "_models.VmDiskTypes"]] = None, **kwargs ): """ - :keyword vm_disk_type: VM disk types which are disallowed. Possible values include: "None", + :keyword vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :paramtype vm_disk_type: str or ~azure.mgmt.compute.v2021_03_01.models.VmDiskTypes """ @@ -2962,8 +2961,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -3005,8 +3004,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -3030,7 +3029,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.compute.v2021_03_01.models.ExtendedLocationTypes """ @@ -3043,13 +3042,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.compute.v2021_03_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -3075,7 +3074,7 @@ def __init__( self, *, name: Optional[str] = None, - properties: Optional["CloudServiceExtensionProperties"] = None, + properties: Optional["_models.CloudServiceExtensionProperties"] = None, **kwargs ): """ @@ -3103,7 +3102,7 @@ class HardwareProfile(msrest.serialization.Model): `_. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The - available VM sizes depend on region and availability set. Possible values include: "Basic_A0", + available VM sizes depend on region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", @@ -3148,7 +3147,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -3163,7 +3162,7 @@ def __init__( `_. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The - available VM sizes depend on region and availability set. Possible values include: "Basic_A0", + available VM sizes depend on region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", @@ -3232,8 +3231,8 @@ class Image(Resource): :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Possible - values include: "V1", "V2". + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_03_01.models.HyperVGenerationTypes """ @@ -3264,10 +3263,10 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -3285,7 +3284,7 @@ def __init__( from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the user to specify the property if we cannot deduce it from the source managed - resource. Possible values include: "V1", "V2". + resource. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_03_01.models.HyperVGenerationTypes """ @@ -3309,16 +3308,15 @@ class ImageDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_03_01.models.StorageAccountTypes @@ -3341,13 +3339,13 @@ class ImageDisk(msrest.serialization.Model): def __init__( self, *, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3360,16 +3358,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_03_01.models.StorageAccountTypes @@ -3402,16 +3399,15 @@ class ImageDataDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_03_01.models.StorageAccountTypes @@ -3444,13 +3440,13 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3463,16 +3459,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_03_01.models.StorageAccountTypes @@ -3513,7 +3508,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -3543,16 +3538,15 @@ class ImageOSDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_03_01.models.StorageAccountTypes @@ -3562,10 +3556,10 @@ class ImageOSDisk(ImageDisk): ~azure.mgmt.compute.v2021_03_01.models.DiskEncryptionSetParameters :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemStateTypes """ @@ -3589,15 +3583,15 @@ class ImageOSDisk(ImageDisk): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3610,16 +3604,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_03_01.models.StorageAccountTypes @@ -3629,11 +3622,10 @@ def __init__( ~azure.mgmt.compute.v2021_03_01.models.DiskEncryptionSetParameters :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemStateTypes """ super(ImageOSDisk, self).__init__(snapshot=snapshot, managed_disk=managed_disk, blob_uri=blob_uri, caching=caching, disk_size_gb=disk_size_gb, storage_account_type=storage_account_type, disk_encryption_set=disk_encryption_set, **kwargs) @@ -3742,8 +3734,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -3784,8 +3776,8 @@ class ImageUpdate(UpdateResource): :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Possible - values include: "V1", "V2". + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_03_01.models.HyperVGenerationTypes """ @@ -3806,9 +3798,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -3822,7 +3814,7 @@ def __init__( from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the user to specify the property if we cannot deduce it from the source managed - resource. Possible values include: "V1", "V2". + resource. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_03_01.models.HyperVGenerationTypes """ @@ -3902,7 +3894,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2021_03_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -3924,7 +3916,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -3933,7 +3925,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2021_03_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -4002,7 +3994,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -4041,7 +4033,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -4062,8 +4054,8 @@ class LastPatchInstallationSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_03_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -4170,9 +4162,9 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, provision_vm_agent: Optional[bool] = None, - patch_settings: Optional["LinuxPatchSettings"] = None, + patch_settings: Optional["_models.LinuxPatchSettings"] = None, **kwargs ): """ @@ -4225,7 +4217,7 @@ class LinuxParameters(msrest.serialization.Model): def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "VMGuestPatchClassificationLinux"]]] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationLinux"]]] = None, package_name_masks_to_include: Optional[List[str]] = None, package_name_masks_to_exclude: Optional[List[str]] = None, maintenance_run_id: Optional[str] = None, @@ -4261,15 +4253,15 @@ class LinuxPatchSettings(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. Possible values include: "ImageDefault", + The property provisionVMAgent must be true. Known values are: "ImageDefault", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2021_03_01.models.LinuxVMGuestPatchMode :ivar assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :vartype assessment_mode: str or ~azure.mgmt.compute.v2021_03_01.models.LinuxPatchAssessmentMode """ @@ -4282,8 +4274,8 @@ class LinuxPatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "LinuxVMGuestPatchMode"]] = None, - assessment_mode: Optional[Union[str, "LinuxPatchAssessmentMode"]] = None, + patch_mode: Optional[Union[str, "_models.LinuxVMGuestPatchMode"]] = None, + assessment_mode: Optional[Union[str, "_models.LinuxPatchAssessmentMode"]] = None, **kwargs ): """ @@ -4292,15 +4284,15 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. Possible values include: "ImageDefault", + The property provisionVMAgent must be true. Known values are: "ImageDefault", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2021_03_01.models.LinuxVMGuestPatchMode :keyword assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :paramtype assessment_mode: str or ~azure.mgmt.compute.v2021_03_01.models.LinuxPatchAssessmentMode """ @@ -4333,7 +4325,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -4377,7 +4369,7 @@ def __init__( self, *, name: str, - properties: "LoadBalancerConfigurationProperties", + properties: "_models.LoadBalancerConfigurationProperties", id: Optional[str] = None, **kwargs ): @@ -4419,7 +4411,7 @@ class LoadBalancerConfigurationProperties(msrest.serialization.Model): def __init__( self, *, - frontend_ip_configurations: List["LoadBalancerFrontendIPConfiguration"], + frontend_ip_configurations: List["_models.LoadBalancerFrontendIPConfiguration"], **kwargs ): """ @@ -4460,7 +4452,7 @@ def __init__( self, *, name: str, - properties: "LoadBalancerFrontendIPConfigurationProperties", + properties: "_models.LoadBalancerFrontendIPConfigurationProperties", **kwargs ): """ @@ -4496,8 +4488,8 @@ class LoadBalancerFrontendIPConfigurationProperties(msrest.serialization.Model): def __init__( self, *, - public_ip_address: Optional["SubResource"] = None, - subnet: Optional["SubResource"] = None, + public_ip_address: Optional["_models.SubResource"] = None, + subnet: Optional["_models.SubResource"] = None, private_ip_address: Optional[str] = None, **kwargs ): @@ -4667,8 +4659,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2021_03_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -4693,7 +4685,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -4709,8 +4701,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2021_03_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -4733,9 +4725,8 @@ class ManagedDiskParameters(SubResource): :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can - only be used with data disks, it cannot be used with OS Disk. Possible values include: - "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", - "StandardSSD_ZRS". + only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", + "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_03_01.models.StorageAccountTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -4754,8 +4745,8 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -4763,7 +4754,7 @@ def __init__( :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS - can only be used with data disks, it cannot be used with OS Disk. Possible values include: + can only be used with data disks, it cannot be used with OS Disk. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or @@ -4787,7 +4778,7 @@ class NetworkInterfaceReference(SubResource): than 1 network interface. :vartype primary: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions """ @@ -4802,7 +4793,7 @@ def __init__( *, id: Optional[str] = None, primary: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -4812,7 +4803,7 @@ def __init__( than 1 network interface. :paramtype primary: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions """ super(NetworkInterfaceReference, self).__init__(id=id, **kwargs) @@ -4828,8 +4819,7 @@ class NetworkProfile(msrest.serialization.Model): :vartype network_interfaces: list[~azure.mgmt.compute.v2021_03_01.models.NetworkInterfaceReference] :ivar network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. Possible values include: - "2020-11-01". + networking resources in the Network Interface Configurations. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2021_03_01.models.NetworkApiVersion :ivar network_interface_configurations: Specifies the networking configurations that will be used to create the virtual machine networking resources. @@ -4846,9 +4836,9 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, - network_interface_configurations: Optional[List["VirtualMachineNetworkInterfaceConfiguration"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceConfiguration"]] = None, **kwargs ): """ @@ -4857,8 +4847,7 @@ def __init__( :paramtype network_interfaces: list[~azure.mgmt.compute.v2021_03_01.models.NetworkInterfaceReference] :keyword network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. Possible values include: - "2020-11-01". + networking resources in the Network Interface Configurations. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_03_01.models.NetworkApiVersion :keyword network_interface_configurations: Specifies the networking configurations that will be used to create the virtual machine networking resources. @@ -4876,11 +4865,9 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :ivar service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2021_03_01.models.OrchestrationServiceNames - :ivar action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :ivar action: Required. The action to be performed. Known values are: "Resume", "Suspend". :vartype action: str or ~azure.mgmt.compute.v2021_03_01.models.OrchestrationServiceStateAction """ @@ -4897,17 +4884,15 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): def __init__( self, *, - service_name: Union[str, "OrchestrationServiceNames"], - action: Union[str, "OrchestrationServiceStateAction"], + service_name: Union[str, "_models.OrchestrationServiceNames"], + action: Union[str, "_models.OrchestrationServiceStateAction"], **kwargs ): """ - :keyword service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :keyword service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :paramtype service_name: str or ~azure.mgmt.compute.v2021_03_01.models.OrchestrationServiceNames - :keyword action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :keyword action: Required. The action to be performed. Known values are: "Resume", "Suspend". :paramtype action: str or ~azure.mgmt.compute.v2021_03_01.models.OrchestrationServiceStateAction """ @@ -4921,9 +4906,9 @@ class OrchestrationServiceSummary(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar service_name: The name of the service. Possible values include: "AutomaticRepairs". + :ivar service_name: The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2021_03_01.models.OrchestrationServiceNames - :ivar service_state: The current state of the service. Possible values include: "NotRunning", + :ivar service_state: The current state of the service. Known values are: "NotRunning", "Running", "Suspended". :vartype service_state: str or ~azure.mgmt.compute.v2021_03_01.models.OrchestrationServiceState """ @@ -4956,8 +4941,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -4973,8 +4958,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -4988,7 +4972,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5001,8 +4985,8 @@ class OSDisk(msrest.serialization.Model): used, the OS disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the os disk is retained after VM is deleted. :code:`
`:code:`
` The default value is set to **detach**. For an ephemeral OS Disk, the default value is set to - **Delete**. User cannot change the delete option for ephemeral OS Disk. Possible values - include: "Delete", "Detach". + **Delete**. User cannot change the delete option for ephemeral OS Disk. Known values are: + "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskDeleteOptionTypes """ @@ -5028,25 +5012,25 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -5062,8 +5046,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -5077,7 +5060,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -5090,8 +5073,8 @@ def __init__( value is used, the OS disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the os disk is retained after VM is deleted. :code:`
`:code:`
` The default value is set to **detach**. For an ephemeral OS Disk, the default value is set to - **Delete**. User cannot change the delete option for ephemeral OS Disk. Possible values - include: "Delete", "Detach". + **Delete**. User cannot change the delete option for ephemeral OS Disk. Known values are: + "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskDeleteOptionTypes """ super(OSDisk, self).__init__(**kwargs) @@ -5114,8 +5097,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemTypes """ @@ -5130,12 +5113,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -5177,7 +5160,7 @@ class OSFamily(msrest.serialization.Model): def __init__( self, *, - properties: Optional["OSFamilyProperties"] = None, + properties: Optional["_models.OSFamilyProperties"] = None, **kwargs ): """ @@ -5215,7 +5198,7 @@ class OSFamilyListResult(msrest.serialization.Model): def __init__( self, *, - value: List["OSFamily"], + value: List["_models.OSFamily"], next_link: Optional[str] = None, **kwargs ): @@ -5357,9 +5340,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, require_guest_provision_signal: Optional[bool] = None, **kwargs @@ -5480,7 +5463,7 @@ class OSVersion(msrest.serialization.Model): def __init__( self, *, - properties: Optional["OSVersionProperties"] = None, + properties: Optional["_models.OSVersionProperties"] = None, **kwargs ): """ @@ -5518,7 +5501,7 @@ class OSVersionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["OSVersion"], + value: List["_models.OSVersion"], next_link: Optional[str] = None, **kwargs ): @@ -5644,8 +5627,7 @@ class PatchInstallationDetail(msrest.serialization.Model): :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] :ivar installation_state: The state of the patch after the installation operation completed. - Possible values include: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", - "Pending". + Known values are: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", "Pending". :vartype installation_state: str or ~azure.mgmt.compute.v2021_03_01.models.PatchInstallationState """ @@ -5695,8 +5677,8 @@ class PatchSettings(msrest.serialization.Model): **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2021_03_01.models.WindowsVMGuestPatchMode :ivar enable_hotpatching: Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must @@ -5706,8 +5688,8 @@ class PatchSettings(msrest.serialization.Model): machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :vartype assessment_mode: str or ~azure.mgmt.compute.v2021_03_01.models.WindowsPatchAssessmentMode """ @@ -5721,9 +5703,9 @@ class PatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "WindowsVMGuestPatchMode"]] = None, + patch_mode: Optional[Union[str, "_models.WindowsVMGuestPatchMode"]] = None, enable_hotpatching: Optional[bool] = None, - assessment_mode: Optional[Union[str, "WindowsPatchAssessmentMode"]] = None, + assessment_mode: Optional[Union[str, "_models.WindowsPatchAssessmentMode"]] = None, **kwargs ): """ @@ -5736,8 +5718,8 @@ def __init__( **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2021_03_01.models.WindowsVMGuestPatchMode :keyword enable_hotpatching: Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must @@ -5747,8 +5729,8 @@ def __init__( machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :paramtype assessment_mode: str or ~azure.mgmt.compute.v2021_03_01.models.WindowsPatchAssessmentMode """ @@ -5826,7 +5808,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2021_03_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -5873,8 +5855,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -5885,7 +5867,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2021_03_01.models.ProximityPlacementGroupType :keyword colocation_status: Describes colocation status of the Proximity Placement Group. @@ -5922,7 +5904,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -6001,9 +5983,9 @@ def __init__( class PublicIPAddressSku(msrest.serialization.Model): """Describes the public IP Sku. - :ivar name: Specify public IP sku name. Possible values include: "Basic", "Standard". + :ivar name: Specify public IP sku name. Known values are: "Basic", "Standard". :vartype name: str or ~azure.mgmt.compute.v2021_03_01.models.PublicIPAddressSkuName - :ivar tier: Specify public IP sku tier. Possible values include: "Regional", "Global". + :ivar tier: Specify public IP sku tier. Known values are: "Regional", "Global". :vartype tier: str or ~azure.mgmt.compute.v2021_03_01.models.PublicIPAddressSkuTier """ @@ -6015,14 +5997,14 @@ class PublicIPAddressSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "PublicIPAddressSkuName"]] = None, - tier: Optional[Union[str, "PublicIPAddressSkuTier"]] = None, + name: Optional[Union[str, "_models.PublicIPAddressSkuName"]] = None, + tier: Optional[Union[str, "_models.PublicIPAddressSkuTier"]] = None, **kwargs ): """ - :keyword name: Specify public IP sku name. Possible values include: "Basic", "Standard". + :keyword name: Specify public IP sku name. Known values are: "Basic", "Standard". :paramtype name: str or ~azure.mgmt.compute.v2021_03_01.models.PublicIPAddressSkuName - :keyword tier: Specify public IP sku tier. Possible values include: "Regional", "Global". + :keyword tier: Specify public IP sku tier. Known values are: "Regional", "Global". :paramtype tier: str or ~azure.mgmt.compute.v2021_03_01.models.PublicIPAddressSkuTier """ super(PublicIPAddressSku, self).__init__(**kwargs) @@ -6135,7 +6117,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_user_agent: Group query result by User Agent. :vartype group_by_user_agent: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2021_03_01.models.IntervalInMins """ @@ -6164,7 +6146,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -6191,7 +6173,7 @@ def __init__( :keyword group_by_user_agent: Group query result by User Agent. :paramtype group_by_user_agent: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2021_03_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, group_by_client_application_id=group_by_client_application_id, group_by_user_agent=group_by_user_agent, **kwargs) @@ -6211,7 +6193,7 @@ class ResourceInstanceViewStatus(msrest.serialization.Model): :vartype message: str :ivar time: The time of the status. :vartype time: ~datetime.datetime - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2021_03_01.models.StatusLevelTypes """ @@ -6233,11 +6215,11 @@ class ResourceInstanceViewStatus(msrest.serialization.Model): def __init__( self, *, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, **kwargs ): """ - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2021_03_01.models.StatusLevelTypes """ super(ResourceInstanceViewStatus, self).__init__(**kwargs) @@ -6268,7 +6250,7 @@ class RestorePoint(ProxyResource): :ivar provisioning_state: Gets the provisioning state of the restore point. :vartype provisioning_state: str :ivar consistency_mode: Gets the consistency mode for the restore point. Please refer to - https://aka.ms/RestorePoints for more details. Possible values include: "CrashConsistent", + https://aka.ms/RestorePoints for more details. Known values are: "CrashConsistent", "FileSystemConsistent", "ApplicationConsistent". :vartype consistency_mode: str or ~azure.mgmt.compute.v2021_03_01.models.ConsistencyModeTypes :ivar time_created: Gets the creation time of the restore point. @@ -6298,7 +6280,7 @@ class RestorePoint(ProxyResource): def __init__( self, *, - exclude_disks: Optional[List["ApiEntityReference"]] = None, + exclude_disks: Optional[List["_models.ApiEntityReference"]] = None, time_created: Optional[datetime.datetime] = None, **kwargs ): @@ -6373,7 +6355,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source: Optional["RestorePointCollectionSourceProperties"] = None, + source: Optional["_models.RestorePointCollectionSourceProperties"] = None, **kwargs ): """ @@ -6411,7 +6393,7 @@ class RestorePointCollectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RestorePointCollection"]] = None, + value: Optional[List["_models.RestorePointCollection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -6499,7 +6481,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["RestorePointCollectionSourceProperties"] = None, + source: Optional["_models.RestorePointCollectionSourceProperties"] = None, **kwargs ): """ @@ -6553,13 +6535,13 @@ class RestorePointSourceMetadata(msrest.serialization.Model): def __init__( self, *, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["RestorePointSourceVMStorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.RestorePointSourceVMStorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, license_type: Optional[str] = None, vm_id: Optional[str] = None, - security_profile: Optional["SecurityProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, location: Optional[str] = None, **kwargs ): @@ -6600,7 +6582,7 @@ class RestorePointSourceVMDataDisk(msrest.serialization.Model): :vartype lun: int :ivar name: Gets the disk name. :vartype name: str - :ivar caching: Gets the caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :ivar disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired size for existing OS and Data disks. @@ -6625,10 +6607,10 @@ def __init__( *, lun: Optional[int] = None, name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - disk_restore_point: Optional["ApiEntityReference"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + disk_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs ): """ @@ -6636,8 +6618,7 @@ def __init__( :paramtype lun: int :keyword name: Gets the disk name. :paramtype name: str - :keyword caching: Gets the caching type. Possible values include: "None", "ReadOnly", - "ReadWrite". + :keyword caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :keyword disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired size for existing OS and Data disks. @@ -6659,13 +6640,13 @@ def __init__( class RestorePointSourceVMOSDisk(msrest.serialization.Model): """Describes an Operating System disk. - :ivar os_type: Gets the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: Gets the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemType :ivar encryption_settings: Gets the disk encryption settings. :vartype encryption_settings: ~azure.mgmt.compute.v2021_03_01.models.DiskEncryptionSettings :ivar name: Gets the disk name. :vartype name: str - :ivar caching: Gets the caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :ivar disk_size_gb: Gets the disk size in GB. :vartype disk_size_gb: int @@ -6688,24 +6669,23 @@ class RestorePointSourceVMOSDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Optional[Union[str, "OperatingSystemType"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemType"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - disk_restore_point: Optional["ApiEntityReference"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + disk_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs ): """ - :keyword os_type: Gets the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: Gets the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemType :keyword encryption_settings: Gets the disk encryption settings. :paramtype encryption_settings: ~azure.mgmt.compute.v2021_03_01.models.DiskEncryptionSettings :keyword name: Gets the disk name. :paramtype name: str - :keyword caching: Gets the caching type. Possible values include: "None", "ReadOnly", - "ReadWrite". + :keyword caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :keyword disk_size_gb: Gets the disk size in GB. :paramtype disk_size_gb: int @@ -6742,8 +6722,8 @@ class RestorePointSourceVMStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["RestorePointSourceVMOSDisk"] = None, - data_disks: Optional[List["RestorePointSourceVMDataDisk"]] = None, + os_disk: Optional["_models.RestorePointSourceVMOSDisk"] = None, + data_disks: Optional[List["_models.RestorePointSourceVMDataDisk"]] = None, **kwargs ): """ @@ -6834,8 +6814,8 @@ class RoleInstance(msrest.serialization.Model): def __init__( self, *, - sku: Optional["InstanceSku"] = None, - properties: Optional["RoleInstanceProperties"] = None, + sku: Optional["_models.InstanceSku"] = None, + properties: Optional["_models.RoleInstanceProperties"] = None, **kwargs ): """ @@ -6877,7 +6857,7 @@ class RoleInstanceListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RoleInstance"], + value: List["_models.RoleInstance"], next_link: Optional[str] = None, **kwargs ): @@ -6937,8 +6917,8 @@ class RoleInstanceProperties(msrest.serialization.Model): def __init__( self, *, - network_profile: Optional["RoleInstanceNetworkProfile"] = None, - instance_view: Optional["RoleInstanceView"] = None, + network_profile: Optional["_models.RoleInstanceNetworkProfile"] = None, + instance_view: Optional["_models.RoleInstanceView"] = None, **kwargs ): """ @@ -7211,13 +7191,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2021_03_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2021_03_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -7330,8 +7310,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -7360,7 +7339,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -7370,8 +7349,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -7395,8 +7373,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -7432,11 +7409,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -7444,8 +7421,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -7491,7 +7467,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -7572,7 +7548,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -7655,7 +7631,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -7694,7 +7670,7 @@ class ScaleInPolicy(msrest.serialization.Model): def __init__( self, *, - rules: Optional[List[Union[str, "VirtualMachineScaleSetScaleInRules"]]] = None, + rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, **kwargs ): """ @@ -7735,7 +7711,7 @@ class ScheduledEventsProfile(msrest.serialization.Model): def __init__( self, *, - terminate_notification_profile: Optional["TerminateNotificationProfile"] = None, + terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs ): """ @@ -7762,8 +7738,7 @@ class SecurityProfile(msrest.serialization.Model): :vartype encryption_at_host: bool :ivar security_type: Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not - be enabled unless this property is set as TrustedLaunch. Possible values include: - "TrustedLaunch". + be enabled unless this property is set as TrustedLaunch. Known values are: "TrustedLaunch". :vartype security_type: str or ~azure.mgmt.compute.v2021_03_01.models.SecurityTypes """ @@ -7776,9 +7751,9 @@ class SecurityProfile(msrest.serialization.Model): def __init__( self, *, - uefi_settings: Optional["UefiSettings"] = None, + uefi_settings: Optional["_models.UefiSettings"] = None, encryption_at_host: Optional[bool] = None, - security_type: Optional[Union[str, "SecurityTypes"]] = None, + security_type: Optional[Union[str, "_models.SecurityTypes"]] = None, **kwargs ): """ @@ -7793,8 +7768,7 @@ def __init__( :paramtype encryption_at_host: bool :keyword security_type: Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not - be enabled unless this property is set as TrustedLaunch. Possible values include: - "TrustedLaunch". + be enabled unless this property is set as TrustedLaunch. Known values are: "TrustedLaunch". :paramtype security_type: str or ~azure.mgmt.compute.v2021_03_01.models.SecurityTypes """ super(SecurityProfile, self).__init__(**kwargs) @@ -7860,7 +7834,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -8055,7 +8029,7 @@ class SshPublicKeysGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["SshPublicKeyResource"], + value: List["_models.SshPublicKeyResource"], next_link: Optional[str] = None, **kwargs ): @@ -8169,9 +8143,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -8243,7 +8217,7 @@ def __init__( self, *, id: Optional[str] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -8462,7 +8436,7 @@ class UpdateDomainListResult(msrest.serialization.Model): def __init__( self, *, - value: List["UpdateDomain"], + value: List["_models.UpdateDomain"], next_link: Optional[str] = None, **kwargs ): @@ -8526,7 +8500,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2021_03_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2021_03_01.models.ApiErrorAutoGenerated - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2021_03_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -8573,7 +8547,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2021_03_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -8613,8 +8587,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2021_03_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -8634,9 +8608,9 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["AutomaticOSUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, + automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, **kwargs ): """ @@ -8644,8 +8618,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2021_03_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -8699,7 +8673,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -8861,8 +8835,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -8979,14 +8953,13 @@ class VirtualMachine(Resource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_03_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -9091,29 +9064,29 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, platform_fault_domain: Optional[int] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, **kwargs ): @@ -9180,15 +9153,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_03_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -9286,8 +9258,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -9312,8 +9284,8 @@ class VirtualMachineAssessPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_03_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -9560,7 +9532,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -9629,7 +9601,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -9766,8 +9738,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -9804,7 +9776,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -9945,8 +9917,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2021_03_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -9970,15 +9942,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2021_03_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -10032,7 +10004,7 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, **kwargs ): """ @@ -10083,8 +10055,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2021_03_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: "V1", - "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_03_01.models.HyperVGenerationTypes :ivar disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -10121,14 +10092,14 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, - disallowed: Optional["DisallowedConfiguration"] = None, - features: Optional[List["VirtualMachineImageFeature"]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, + automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, + disallowed: Optional["_models.DisallowedConfiguration"] = None, + features: Optional[List["_models.VirtualMachineImageFeature"]] = None, **kwargs ): """ @@ -10155,8 +10126,7 @@ def __init__( image. :paramtype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2021_03_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: - "V1", "V2". + :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_03_01.models.HyperVGenerationTypes :keyword disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -10216,7 +10186,7 @@ class VirtualMachineInstallPatchesParameters(msrest.serialization.Model): run. It must be an ISO 8601-compliant duration string such as PT4H (4 hours). :vartype maximum_duration: str :ivar reboot_setting: Required. Defines when it is acceptable to reboot a VM during a software - update operation. Possible values include: "IfRequired", "Never", "Always". + update operation. Known values are: "IfRequired", "Never", "Always". :vartype reboot_setting: str or ~azure.mgmt.compute.v2021_03_01.models.VMGuestPatchRebootSetting :ivar windows_parameters: Input for InstallPatches on a Windows VM, as directly received by the @@ -10243,9 +10213,9 @@ def __init__( self, *, maximum_duration: str, - reboot_setting: Union[str, "VMGuestPatchRebootSetting"], - windows_parameters: Optional["WindowsParameters"] = None, - linux_parameters: Optional["LinuxParameters"] = None, + reboot_setting: Union[str, "_models.VMGuestPatchRebootSetting"], + windows_parameters: Optional["_models.WindowsParameters"] = None, + linux_parameters: Optional["_models.LinuxParameters"] = None, **kwargs ): """ @@ -10253,7 +10223,7 @@ def __init__( will run. It must be an ISO 8601-compliant duration string such as PT4H (4 hours). :paramtype maximum_duration: str :keyword reboot_setting: Required. Defines when it is acceptable to reboot a VM during a - software update operation. Possible values include: "IfRequired", "Never", "Always". + software update operation. Known values are: "IfRequired", "Never", "Always". :paramtype reboot_setting: str or ~azure.mgmt.compute.v2021_03_01.models.VMGuestPatchRebootSetting :keyword windows_parameters: Input for InstallPatches on a Windows VM, as directly received by @@ -10277,14 +10247,14 @@ class VirtualMachineInstallPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Failed", "Succeeded", "Unknown" or - "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_03_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. :vartype installation_activity_id: str - :ivar reboot_status: The reboot state of the VM following completion of the operation. Possible - values include: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". + :ivar reboot_status: The reboot state of the VM following completion of the operation. Known + values are: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". :vartype reboot_status: str or ~azure.mgmt.compute.v2021_03_01.models.VMGuestPatchRebootStatus :ivar maintenance_window_exceeded: Whether the operation ran out of time before it completed all its intended actions. @@ -10379,8 +10349,8 @@ class VirtualMachineInstanceView(msrest.serialization.Model): :vartype os_name: str :ivar os_version: The version of Operating System running on the virtual machine. :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_03_01.models.HyperVGenerationType :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. :vartype rdp_thumb_print: str @@ -10444,15 +10414,15 @@ def __init__( computer_name: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationType"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, - patch_status: Optional["VirtualMachinePatchStatus"] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, + patch_status: Optional["_models.VirtualMachinePatchStatus"] = None, **kwargs ): """ @@ -10467,7 +10437,7 @@ def __init__( :keyword os_version: The version of Operating System running on the virtual machine. :paramtype os_version: str :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_03_01.models.HyperVGenerationType :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. @@ -10567,7 +10537,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -10594,7 +10564,7 @@ class VirtualMachineNetworkInterfaceConfiguration(msrest.serialization.Model): than 1 network interface. :vartype primary: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated networking-enabled. @@ -10637,14 +10607,14 @@ def __init__( *, name: str, primary: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, enable_ip_forwarding: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineNetworkInterfaceDnsSettingsConfiguration"] = None, - ip_configurations: Optional[List["VirtualMachineNetworkInterfaceIPConfiguration"]] = None, - dscp_configuration: Optional["SubResource"] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineNetworkInterfaceDnsSettingsConfiguration"] = None, + ip_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceIPConfiguration"]] = None, + dscp_configuration: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -10654,7 +10624,7 @@ def __init__( than 1 network interface. :paramtype primary: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated networking-enabled. @@ -10729,7 +10699,7 @@ class VirtualMachineNetworkInterfaceIPConfiguration(msrest.serialization.Model): ~azure.mgmt.compute.v2021_03_01.models.VirtualMachinePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_03_01.models.IPVersions :ivar application_security_groups: Specifies an array of references to application security group. @@ -10767,13 +10737,13 @@ def __init__( self, *, name: str, - subnet: Optional["SubResource"] = None, + subnet: Optional["_models.SubResource"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachinePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersions"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachinePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersions"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -10789,7 +10759,7 @@ def __init__( ~azure.mgmt.compute.v2021_03_01.models.VirtualMachinePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_03_01.models.IPVersions :keyword application_security_groups: Specifies an array of references to application security group. @@ -10849,8 +10819,8 @@ class VirtualMachinePatchStatus(msrest.serialization.Model): def __init__( self, *, - available_patch_summary: Optional["AvailablePatchSummary"] = None, - last_patch_installation_summary: Optional["LastPatchInstallationSummary"] = None, + available_patch_summary: Optional["_models.AvailablePatchSummary"] = None, + last_patch_installation_summary: Optional["_models.LastPatchInstallationSummary"] = None, **kwargs ): """ @@ -10881,7 +10851,7 @@ class VirtualMachinePublicIPAddressConfiguration(msrest.serialization.Model): :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. :vartype idle_timeout_in_minutes: int :ivar delete_option: Specify what happens to the public IP address when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions :ivar dns_settings: The dns settings to be applied on the publicIP addresses . :vartype dns_settings: @@ -10892,10 +10862,10 @@ class VirtualMachinePublicIPAddressConfiguration(msrest.serialization.Model): :vartype public_ip_prefix: ~azure.mgmt.compute.v2021_03_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2021_03_01.models.IPVersions - :ivar public_ip_allocation_method: Specify the public IP allocation type. Possible values - include: "Dynamic", "Static". + :ivar public_ip_allocation_method: Specify the public IP allocation type. Known values are: + "Dynamic", "Static". :vartype public_ip_allocation_method: str or ~azure.mgmt.compute.v2021_03_01.models.PublicIPAllocationMethod """ @@ -10920,14 +10890,14 @@ def __init__( self, *, name: str, - sku: Optional["PublicIPAddressSku"] = None, + sku: Optional["_models.PublicIPAddressSku"] = None, idle_timeout_in_minutes: Optional[int] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, - dns_settings: Optional["VirtualMachinePublicIPAddressDnsSettingsConfiguration"] = None, - ip_tags: Optional[List["VirtualMachineIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersions"]] = None, - public_ip_allocation_method: Optional[Union[str, "PublicIPAllocationMethod"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachinePublicIPAddressDnsSettingsConfiguration"] = None, + ip_tags: Optional[List["_models.VirtualMachineIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersions"]] = None, + public_ip_allocation_method: Optional[Union[str, "_models.PublicIPAllocationMethod"]] = None, **kwargs ): """ @@ -10938,7 +10908,7 @@ def __init__( :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. :paramtype idle_timeout_in_minutes: int :keyword delete_option: Specify what happens to the public IP address when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions :keyword dns_settings: The dns settings to be applied on the publicIP addresses . :paramtype dns_settings: @@ -10949,10 +10919,10 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2021_03_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2021_03_01.models.IPVersions - :keyword public_ip_allocation_method: Specify the public IP allocation type. Possible values - include: "Dynamic", "Static". + :keyword public_ip_allocation_method: Specify the public IP allocation type. Known values are: + "Dynamic", "Static". :paramtype public_ip_allocation_method: str or ~azure.mgmt.compute.v2021_03_01.models.PublicIPAllocationMethod """ @@ -11110,9 +11080,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -11167,7 +11137,7 @@ def __init__( class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): """The instance view of a virtual machine run command. - :ivar execution_state: Script execution status. Possible values include: "Unknown", "Pending", + :ivar execution_state: Script execution status. Known values are: "Unknown", "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :vartype execution_state: str or ~azure.mgmt.compute.v2021_03_01.models.ExecutionState :ivar execution_message: Communicate script configuration errors or execution messages. @@ -11200,19 +11170,19 @@ class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): def __init__( self, *, - execution_state: Optional[Union[str, "ExecutionState"]] = None, + execution_state: Optional[Union[str, "_models.ExecutionState"]] = None, execution_message: Optional[str] = None, exit_code: Optional[int] = None, output: Optional[str] = None, error: Optional[str] = None, start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ - :keyword execution_state: Script execution status. Possible values include: "Unknown", - "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". + :keyword execution_state: Script execution status. Known values are: "Unknown", "Pending", + "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :paramtype execution_state: str or ~azure.mgmt.compute.v2021_03_01.models.ExecutionState :keyword execution_message: Communicate script configuration errors or execution messages. :paramtype execution_message: str @@ -11302,7 +11272,7 @@ class VirtualMachineRunCommandsListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineRunCommand"], + value: List["_models.VirtualMachineRunCommand"], next_link: Optional[str] = None, **kwargs ): @@ -11378,9 +11348,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -11505,7 +11475,7 @@ class VirtualMachineScaleSet(Resource): chosen for removal when a Virtual Machine Scale Set is scaled-in. :vartype scale_in_policy: ~azure.mgmt.compute.v2021_03_01.models.ScaleInPolicy :ivar orchestration_mode: Specifies the orchestration mode for the virtual machine scale set. - Possible values include: "Uniform", "Flexible". + Known values are: "Uniform", "Flexible". :vartype orchestration_mode: str or ~azure.mgmt.compute.v2021_03_01.models.OrchestrationMode """ @@ -11551,24 +11521,24 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - orchestration_mode: Optional[Union[str, "OrchestrationMode"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + orchestration_mode: Optional[Union[str, "_models.OrchestrationMode"]] = None, **kwargs ): """ @@ -11632,7 +11602,7 @@ def __init__( chosen for removal when a Virtual Machine Scale Set is scaled-in. :paramtype scale_in_policy: ~azure.mgmt.compute.v2021_03_01.models.ScaleInPolicy :keyword orchestration_mode: Specifies the orchestration mode for the virtual machine scale - set. Possible values include: "Uniform", "Flexible". + set. Known values are: "Uniform", "Flexible". :paramtype orchestration_mode: str or ~azure.mgmt.compute.v2021_03_01.models.OrchestrationMode """ super(VirtualMachineScaleSet, self).__init__(location=location, tags=tags, **kwargs) @@ -11672,14 +11642,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -11719,12 +11688,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -11739,14 +11708,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -11921,7 +11889,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -11958,7 +11926,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, extensions_time_budget: Optional[str] = None, **kwargs ): @@ -12110,7 +12078,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2021_03_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine @@ -12135,15 +12103,15 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2021_03_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual @@ -12226,7 +12194,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -12287,7 +12255,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_03_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -12331,14 +12299,14 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -12356,7 +12324,7 @@ def __init__( ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_03_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -12448,7 +12416,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -12489,7 +12457,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -12529,7 +12497,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -12569,7 +12537,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -12589,8 +12557,8 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): """Describes the parameters of a ScaleSet managed disk. :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_03_01.models.StorageAccountTypes @@ -12608,14 +12576,14 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_03_01.models.StorageAccountTypes @@ -12657,7 +12625,7 @@ class VirtualMachineScaleSetNetworkConfiguration(SubResource): :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions """ @@ -12686,11 +12654,11 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -12717,7 +12685,7 @@ def __init__( :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions """ super(VirtualMachineScaleSetNetworkConfiguration, self).__init__(id=id, **kwargs) @@ -12769,7 +12737,7 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetNetworkConfiguration] :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2021_03_01.models.NetworkApiVersion """ @@ -12782,9 +12750,9 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, **kwargs ): """ @@ -12797,7 +12765,7 @@ def __init__( list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetNetworkConfiguration] :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_03_01.models.NetworkApiVersion """ super(VirtualMachineScaleSetNetworkProfile, self).__init__(**kwargs) @@ -12816,8 +12784,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -12826,8 +12793,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -12838,8 +12805,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2021_03_01.models.VirtualHardDisk @@ -12871,16 +12838,16 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -12889,8 +12856,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -12899,8 +12865,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_03_01.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -12912,7 +12878,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_03_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2021_03_01.models.VirtualHardDisk @@ -13006,9 +12972,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -13092,10 +13058,10 @@ class VirtualMachineScaleSetPublicIPAddressConfiguration(msrest.serialization.Mo :vartype public_ip_prefix: ~azure.mgmt.compute.v2021_03_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2021_03_01.models.IPVersion - :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values + are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions """ @@ -13118,13 +13084,13 @@ def __init__( self, *, name: str, - sku: Optional["PublicIPAddressSku"] = None, + sku: Optional["_models.PublicIPAddressSku"] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -13143,10 +13109,10 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2021_03_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2021_03_01.models.IPVersion - :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known + values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions """ super(VirtualMachineScaleSetPublicIPAddressConfiguration, self).__init__(**kwargs) @@ -13306,8 +13272,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -13369,9 +13334,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -13462,18 +13427,18 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - proximity_placement_group: Optional["SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -13551,7 +13516,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_03_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -13585,14 +13550,14 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -13610,7 +13575,7 @@ def __init__( ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_03_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -13664,7 +13629,7 @@ class VirtualMachineScaleSetUpdateNetworkConfiguration(SubResource): :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions """ @@ -13689,11 +13654,11 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -13719,7 +13684,7 @@ def __init__( :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions """ super(VirtualMachineScaleSetUpdateNetworkConfiguration, self).__init__(id=id, **kwargs) @@ -13746,7 +13711,7 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2021_03_01.models.NetworkApiVersion """ @@ -13759,9 +13724,9 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, **kwargs ): """ @@ -13774,7 +13739,7 @@ def __init__( list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_03_01.models.NetworkApiVersion """ super(VirtualMachineScaleSetUpdateNetworkProfile, self).__init__(**kwargs) @@ -13786,7 +13751,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -13818,16 +13783,16 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -13879,9 +13844,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -13911,8 +13876,8 @@ class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration(msrest.serializat :ivar dns_settings: The dns settings to be applied on the publicIP addresses . :vartype dns_settings: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values + are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions """ @@ -13928,8 +13893,8 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -13940,8 +13905,8 @@ def __init__( :keyword dns_settings: The dns settings to be applied on the publicIP addresses . :paramtype dns_settings: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known + values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_03_01.models.DeleteOptions """ super(VirtualMachineScaleSetUpdatePublicIPAddressConfiguration, self).__init__(**kwargs) @@ -13972,9 +13937,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -14040,15 +14005,15 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, **kwargs ): @@ -14241,18 +14206,18 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - network_profile_configuration: Optional["VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, - protection_policy: Optional["VirtualMachineScaleSetVMProtectionPolicy"] = None, + protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, user_data: Optional[str] = None, **kwargs ): @@ -14418,7 +14383,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -14477,7 +14442,7 @@ class VirtualMachineScaleSetVMExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineScaleSetVMExtension"]] = None, + value: Optional[List["_models.VirtualMachineScaleSetVMExtension"]] = None, **kwargs ): """ @@ -14753,12 +14718,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -14829,7 +14794,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -14860,7 +14825,7 @@ class VirtualMachineScaleSetVMNetworkProfileConfiguration(msrest.serialization.M def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -14907,15 +14872,14 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -14948,17 +14912,17 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, **kwargs ): @@ -14995,15 +14959,14 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -15156,7 +15119,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -15182,7 +15145,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype kb_id: str :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] - :ivar reboot_behavior: Describes the reboot requirements of the patch. Possible values include: + :ivar reboot_behavior: Describes the reboot requirements of the patch. Known values are: "Unknown", "NeverReboots", "AlwaysRequiresReboot", "CanRequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.compute.v2021_03_01.models.VMGuestPatchRebootBehavior @@ -15193,7 +15156,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype published_date: ~datetime.datetime :ivar last_modified_date_time: The UTC timestamp of the last update to this patch record. :vartype last_modified_date_time: ~datetime.datetime - :ivar assessment_state: Describes the availability of a given patch. Possible values include: + :ivar assessment_state: Describes the availability of a given patch. Known values are: "Unknown", "Available". :vartype assessment_state: str or ~azure.mgmt.compute.v2021_03_01.models.PatchAssessmentState """ @@ -15337,14 +15300,13 @@ class VirtualMachineUpdate(UpdateResource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_03_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -15437,28 +15399,28 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, platform_fault_domain: Optional[int] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, **kwargs ): @@ -15521,15 +15483,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_03_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -15679,9 +15640,9 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - patch_settings: Optional["PatchSettings"] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + patch_settings: Optional["_models.PatchSettings"] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -15750,7 +15711,7 @@ class WindowsParameters(msrest.serialization.Model): def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "VMGuestPatchClassificationWindows"]]] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationWindows"]]] = None, kb_numbers_to_include: Optional[List[str]] = None, kb_numbers_to_exclude: Optional[List[str]] = None, exclude_kbs_requiring_reboot: Optional[bool] = None, @@ -15795,7 +15756,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -15810,7 +15771,7 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :vartype protocol: str or ~azure.mgmt.compute.v2021_03_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as @@ -15835,13 +15796,13 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2021_03_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/__init__.py index 1e078da6ebf8..d6527d80373b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/__init__.py @@ -36,6 +36,9 @@ from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations from ._virtual_machine_scale_set_vm_run_commands_operations import VirtualMachineScaleSetVMRunCommandsOperations +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__ = [ 'CloudServiceRoleInstancesOperations', 'CloudServiceRolesOperations', @@ -67,3 +70,5 @@ 'VirtualMachineRunCommandsOperations', 'VirtualMachineScaleSetVMRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_availability_sets_operations.py index bd8362b0992b..7364abbc2727 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +190,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -199,20 +205,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -235,18 +242,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -257,9 +262,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -271,51 +279,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -329,14 +333,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -348,11 +355,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -378,9 +387,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -394,14 +403,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -413,11 +425,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,13 +470,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -471,11 +488,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -498,7 +517,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -510,13 +529,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -525,11 +547,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -555,7 +579,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -568,13 +592,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -583,9 +610,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +623,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -634,7 +665,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -646,13 +677,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +695,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -672,9 +708,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -713,7 +751,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -728,13 +766,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -756,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_service_operating_systems_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_service_operating_systems_operations.py index a8fa300a931c..6683a7859301 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_service_operating_systems_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_service_operating_systems_operations.py @@ -16,6 +16,7 @@ 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 @@ -32,9 +33,12 @@ def build_get_os_version_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions/{osVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -46,18 +50,16 @@ def build_get_os_version_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -67,9 +69,12 @@ def build_list_os_versions_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions") # pylint: disable=line-too-long path_format_arguments = { @@ -80,18 +85,16 @@ def build_list_os_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -102,9 +105,12 @@ def build_get_os_family_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies/{osFamilyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -116,18 +122,16 @@ def build_get_os_family_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -137,9 +141,12 @@ def build_list_os_families_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies") # pylint: disable=line-too-long path_format_arguments = { @@ -150,42 +157,38 @@ def build_list_os_families_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CloudServiceOperatingSystemsOperations(object): - """CloudServiceOperatingSystemsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CloudServiceOperatingSystemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`cloud_service_operating_systems` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_os_version( @@ -193,7 +196,7 @@ def get_os_version( location: str, os_version_name: str, **kwargs: Any - ) -> "_models.OSVersion": + ) -> _models.OSVersion: """Gets properties of a guest operating system version that can be specified in the XML service configuration (.cscfg) for a cloud service. @@ -206,13 +209,16 @@ def get_os_version( :rtype: ~azure.mgmt.compute.v2021_03_01.models.OSVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OSVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSVersion] request = build_get_os_version_request( @@ -221,11 +227,13 @@ def get_os_version( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_version.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -251,7 +259,7 @@ def list_os_versions( self, location: str, **kwargs: Any - ) -> Iterable["_models.OSVersionListResult"]: + ) -> Iterable[_models.OSVersionListResult]: """Gets a list of all guest operating system versions available to be specified in the XML service configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the next page of OS versions. Do this till nextLink is null to fetch all the OS versions. @@ -264,13 +272,16 @@ def list_os_versions( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.OSVersionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSVersionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OSVersionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -279,9 +290,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_os_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -290,9 +303,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -331,7 +346,7 @@ def get_os_family( location: str, os_family_name: str, **kwargs: Any - ) -> "_models.OSFamily": + ) -> _models.OSFamily: """Gets properties of a guest operating system family that can be specified in the XML service configuration (.cscfg) for a cloud service. @@ -344,13 +359,16 @@ def get_os_family( :rtype: ~azure.mgmt.compute.v2021_03_01.models.OSFamily :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OSFamily"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSFamily] request = build_get_os_family_request( @@ -359,11 +377,13 @@ def get_os_family( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_family.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -389,7 +409,7 @@ def list_os_families( self, location: str, **kwargs: Any - ) -> Iterable["_models.OSFamilyListResult"]: + ) -> Iterable[_models.OSFamilyListResult]: """Gets a list of all guest operating system families available to be specified in the XML service configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the next page of OS Families. Do this till nextLink is null to fetch all the OS Families. @@ -401,13 +421,16 @@ def list_os_families( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.OSFamilyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSFamilyListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OSFamilyListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +439,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_os_families.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -427,9 +452,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_service_role_instances_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_service_role_instances_operations.py index 494966388452..ff252f580dc6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_service_role_instances_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_service_role_instances_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,6 +17,7 @@ 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 @@ -35,9 +36,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -50,18 +54,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -75,9 +77,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -90,20 +95,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -115,9 +118,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -130,18 +136,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -154,9 +158,12 @@ def build_list_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances") # pylint: disable=line-too-long path_format_arguments = { @@ -168,20 +175,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -193,9 +198,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -208,18 +216,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +237,12 @@ def build_reimage_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -246,18 +255,16 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -269,9 +276,12 @@ def build_rebuild_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/rebuild") # pylint: disable=line-too-long path_format_arguments = { @@ -284,18 +294,16 @@ def build_rebuild_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -307,9 +315,12 @@ def build_get_remote_desktop_file_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/x-rdp") - accept = "application/x-rdp" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/remoteDesktopFile") # pylint: disable=line-too-long path_format_arguments = { @@ -322,42 +333,38 @@ def build_get_remote_desktop_file_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CloudServiceRoleInstancesOperations(object): - """CloudServiceRoleInstancesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CloudServiceRoleInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`cloud_service_role_instances` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -366,13 +373,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements cloud_service_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -382,11 +392,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -431,21 +443,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +472,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -477,7 +500,7 @@ def get( cloud_service_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.RoleInstance": + ) -> _models.RoleInstance: """Gets a role instance from a cloud service. :param role_instance_name: Name of the role instance. @@ -494,13 +517,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RoleInstance :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstance"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstance] request = build_get_request( @@ -511,11 +537,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -543,7 +571,7 @@ def get_instance_view( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.RoleInstanceView": + ) -> _models.RoleInstanceView: """Retrieves information about the run-time state of a role instance in a cloud service. :param role_instance_name: Name of the role instance. @@ -557,13 +585,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RoleInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstanceView] request = build_get_instance_view_request( @@ -573,11 +604,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -605,7 +638,7 @@ def list( cloud_service_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> Iterable["_models.RoleInstanceListResult"]: + ) -> Iterable[_models.RoleInstanceListResult]: """Gets the list of all role instances in a cloud service. Use nextLink property in the response to get the next page of role instances. Do this till nextLink is null to fetch all the role instances. @@ -624,13 +657,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.RoleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstanceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -641,9 +677,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -654,9 +692,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -696,13 +736,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -712,11 +755,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -762,21 +807,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._restart_initial( + raw_result = self._restart_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -786,8 +836,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -807,13 +863,16 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_request_initial( @@ -823,11 +882,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -873,21 +934,26 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -897,8 +963,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -918,13 +990,16 @@ def _rebuild_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_rebuild_request_initial( @@ -934,11 +1009,13 @@ def _rebuild_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._rebuild_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -985,21 +1062,26 @@ def begin_rebuild( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._rebuild_initial( + raw_result = self._rebuild_initial( # type: ignore role_instance_name=role_instance_name, resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1009,8 +1091,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1044,13 +1132,16 @@ def get_remote_desktop_file( :rtype: IO :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[IO] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[IO] request = build_get_remote_desktop_file_request( @@ -1060,11 +1151,13 @@ def get_remote_desktop_file( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_remote_desktop_file.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=True, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_service_roles_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_service_roles_operations.py index c300e8b57623..0ed07c688ed8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_service_roles_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_service_roles_operations.py @@ -16,6 +16,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles/{roleName}") # pylint: disable=line-too-long path_format_arguments = { @@ -48,18 +52,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -70,9 +72,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles") # pylint: disable=line-too-long path_format_arguments = { @@ -84,42 +89,38 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CloudServiceRolesOperations(object): - """CloudServiceRolesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CloudServiceRolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`cloud_service_roles` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -128,7 +129,7 @@ def get( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.CloudServiceRole": + ) -> _models.CloudServiceRole: """Gets a role from a cloud service. :param role_name: Name of the role. @@ -142,13 +143,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.CloudServiceRole :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceRole"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceRole] request = build_get_request( @@ -158,11 +162,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -189,7 +195,7 @@ def list( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> Iterable["_models.CloudServiceRoleListResult"]: + ) -> Iterable[_models.CloudServiceRoleListResult]: """Gets a list of all roles in a cloud service. Use nextLink property in the response to get the next page of roles. Do this till nextLink is null to fetch all the roles. @@ -204,13 +210,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.CloudServiceRoleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceRoleListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceRoleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -220,9 +229,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -232,9 +243,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_services_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_services_operations.py index f8d9a9032985..24382b2d97c3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_services_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_services_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( cloud_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CloudService] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( cloud_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CloudServiceUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -195,9 +199,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -209,18 +216,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -229,9 +234,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/cloudServices") path_format_arguments = { @@ -241,18 +249,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -262,9 +268,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices") # pylint: disable=line-too-long path_format_arguments = { @@ -275,18 +284,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -297,9 +304,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -311,18 +321,16 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -333,9 +341,12 @@ def build_power_off_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -347,18 +358,16 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -368,14 +377,17 @@ def build_restart_request_initial( cloud_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RoleInstances] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -387,20 +399,18 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -412,14 +422,17 @@ def build_reimage_request_initial( cloud_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RoleInstances] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -431,20 +444,18 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -456,14 +467,17 @@ def build_rebuild_request_initial( cloud_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RoleInstances] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/rebuild") # pylint: disable=line-too-long path_format_arguments = { @@ -475,20 +489,18 @@ def build_rebuild_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -500,14 +512,17 @@ def build_delete_instances_request_initial( cloud_service_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RoleInstances] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -519,62 +534,61 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class CloudServicesOperations(object): # pylint: disable=too-many-public-methods - """CloudServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CloudServicesOperations: # 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`cloud_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") + def _create_or_update_initial( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudService"] = None, + parameters: Optional[_models.CloudService] = None, **kwargs: Any - ) -> "_models.CloudService": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] + ) -> _models.CloudService: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] if parameters is not None: _json = self._serialize.body(parameters, 'CloudService') @@ -589,11 +603,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -623,9 +639,9 @@ def begin_create_or_update( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudService"] = None, + parameters: Optional[_models.CloudService] = None, **kwargs: Any - ) -> LROPoller["_models.CloudService"]: + ) -> LROPoller[_models.CloudService]: """Create or update a cloud service. Please note some properties can be set only during cloud service creation. @@ -648,37 +664,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.CloudService] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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('CloudService', 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( @@ -695,17 +721,20 @@ def _update_initial( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudServiceUpdate"] = None, + parameters: Optional[_models.CloudServiceUpdate] = None, **kwargs: Any - ) -> "_models.CloudService": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] + ) -> _models.CloudService: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] if parameters is not None: _json = self._serialize.body(parameters, 'CloudServiceUpdate') @@ -720,11 +749,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -750,9 +781,9 @@ def begin_update( self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.CloudServiceUpdate"] = None, + parameters: Optional[_models.CloudServiceUpdate] = None, **kwargs: Any - ) -> LROPoller["_models.CloudService"]: + ) -> LROPoller[_models.CloudService]: """Update a cloud service. :param resource_group_name: Name of the resource group. @@ -774,37 +805,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.CloudService] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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('CloudService', 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( @@ -823,13 +864,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements cloud_service_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -838,11 +882,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -884,20 +930,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -907,8 +958,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -927,7 +984,7 @@ def get( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.CloudService": + ) -> _models.CloudService: """Display information about a cloud service. :param resource_group_name: Name of the resource group. @@ -939,13 +996,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.CloudService :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudService"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] request = build_get_request( @@ -954,11 +1014,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -985,7 +1047,7 @@ def get_instance_view( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> "_models.CloudServiceInstanceView": + ) -> _models.CloudServiceInstanceView: """Gets the status of a cloud service. :param resource_group_name: Name of the resource group. @@ -997,13 +1059,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_03_01.models.CloudServiceInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceInstanceView] request = build_get_instance_view_request( @@ -1012,11 +1077,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1041,7 +1108,7 @@ def get_instance_view( def list_all( self, **kwargs: Any - ) -> Iterable["_models.CloudServiceListResult"]: + ) -> Iterable[_models.CloudServiceListResult]: """Gets a list of all cloud services in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud Services. @@ -1053,13 +1120,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.CloudServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1067,9 +1137,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1077,9 +1149,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1117,7 +1191,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.CloudServiceListResult"]: + ) -> Iterable[_models.CloudServiceListResult]: """Gets a list of all cloud services under a resource group. Use nextLink property in the response to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud Services. @@ -1131,13 +1205,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.CloudServiceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudServiceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1146,9 +1223,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1157,9 +1236,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1198,13 +1279,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1213,11 +1297,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1259,20 +1345,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1282,8 +1373,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1302,13 +1399,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements cloud_service_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1317,11 +1417,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1364,20 +1466,25 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1387,8 +1494,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1405,17 +1518,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1430,11 +1546,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1456,7 +1574,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more role instances in a cloud service. @@ -1479,23 +1597,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1505,8 +1628,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1523,17 +1652,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1548,11 +1680,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1574,7 +1708,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> LROPoller[None]: """Reimage asynchronous operation reinstalls the operating system on instances of web roles or @@ -1598,23 +1732,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1624,8 +1763,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1642,17 +1787,20 @@ def _rebuild_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1667,11 +1815,13 @@ def _rebuild_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._rebuild_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1693,7 +1843,7 @@ def begin_rebuild( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> LROPoller[None]: """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker @@ -1718,23 +1868,28 @@ def begin_rebuild( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._rebuild_initial( + raw_result = self._rebuild_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1744,8 +1899,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1762,17 +1923,20 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'RoleInstances') @@ -1787,11 +1951,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1813,7 +1979,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, - parameters: Optional["_models.RoleInstances"] = None, + parameters: Optional[_models.RoleInstances] = None, **kwargs: Any ) -> LROPoller[None]: """Deletes role instances in a cloud service. @@ -1836,23 +2002,28 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_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) @@ -1862,8 +2033,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_services_update_domain_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_services_update_domain_operations.py index 57a57e3b3efd..c53edae3dd93 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_services_update_domain_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_cloud_services_update_domain_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_walk_update_domain_request_initial( update_domain: int, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.UpdateDomain] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_walk_update_domain_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,9 +83,12 @@ def build_get_update_domain_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,18 +101,16 @@ def build_get_update_domain_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -119,9 +121,12 @@ def build_list_update_domains_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains") # pylint: disable=line-too-long path_format_arguments = { @@ -133,59 +138,58 @@ def build_list_update_domains_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CloudServicesUpdateDomainOperations(object): - """CloudServicesUpdateDomainOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CloudServicesUpdateDomainOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`cloud_services_update_domain` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _walk_update_domain_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cloud_service_name: str, update_domain: int, - parameters: Optional["_models.UpdateDomain"] = None, + parameters: Optional[_models.UpdateDomain] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'UpdateDomain') @@ -201,11 +205,13 @@ def _walk_update_domain_initial( # pylint: disable=inconsistent-return-statemen content_type=content_type, json=_json, template_url=self._walk_update_domain_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -228,7 +234,7 @@ def begin_walk_update_domain( # pylint: disable=inconsistent-return-statements resource_group_name: str, cloud_service_name: str, update_domain: int, - parameters: Optional["_models.UpdateDomain"] = None, + parameters: Optional[_models.UpdateDomain] = None, **kwargs: Any ) -> LROPoller[None]: """Updates the role instances in the specified update domain. @@ -255,17 +261,20 @@ def begin_walk_update_domain( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._walk_update_domain_initial( + raw_result = self._walk_update_domain_initial( # type: ignore resource_group_name=resource_group_name, cloud_service_name=cloud_service_name, update_domain=update_domain, @@ -273,6 +282,8 @@ def begin_walk_update_domain( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -282,8 +293,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -303,7 +320,7 @@ def get_update_domain( cloud_service_name: str, update_domain: int, **kwargs: Any - ) -> "_models.UpdateDomain": + ) -> _models.UpdateDomain: """Gets the specified update domain of a cloud service. Use nextLink property in the response to get the next page of update domains. Do this till nextLink is null to fetch all the update domains. @@ -321,13 +338,16 @@ def get_update_domain( :rtype: ~azure.mgmt.compute.v2021_03_01.models.UpdateDomain :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateDomain"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateDomain] request = build_get_update_domain_request( @@ -337,11 +357,13 @@ def get_update_domain( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_update_domain.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -368,7 +390,7 @@ def list_update_domains( resource_group_name: str, cloud_service_name: str, **kwargs: Any - ) -> Iterable["_models.UpdateDomainListResult"]: + ) -> Iterable[_models.UpdateDomainListResult]: """Gets a list of all update domains in a cloud service. :param resource_group_name: Name of the resource group. @@ -382,13 +404,16 @@ def list_update_domains( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.UpdateDomainListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateDomainListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.UpdateDomainListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +423,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_update_domains.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -410,9 +437,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_dedicated_host_groups_operations.py index c90e2a5f3d9d..a5a077f1b1be 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_dedicated_host_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +172,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -190,9 +193,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -203,18 +209,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -223,9 +227,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") path_format_arguments = { @@ -235,51 +242,47 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostGroupsOperations(object): - """DedicatedHostGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -295,14 +298,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -314,11 +320,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -348,9 +356,9 @@ def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -364,14 +372,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -383,11 +394,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -426,13 +439,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -441,11 +457,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -469,7 +487,7 @@ def get( host_group_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -485,13 +503,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -501,11 +522,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -531,7 +554,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -544,13 +567,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -559,9 +585,11 @@ def prepare_request(next_link=None): 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: @@ -570,9 +598,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -609,7 +639,7 @@ def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -620,13 +650,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -634,9 +667,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -644,9 +679,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_dedicated_hosts_operations.py index 9e406a23ff3e..2888c280fba2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHost] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_by_host_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_by_host_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostsOperations(object): - """DedicatedHostsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -341,17 +348,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -359,20 +369,27 @@ def begin_create_or_update( 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('DedicatedHost', 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( @@ -390,17 +407,20 @@ def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -413,11 +433,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -444,9 +466,9 @@ def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -470,17 +492,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -488,20 +513,27 @@ def begin_update( 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('DedicatedHost', 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( @@ -521,13 +553,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements host_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -537,11 +572,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -586,21 +623,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -610,8 +652,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -632,7 +680,7 @@ def get( host_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -650,13 +698,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -667,11 +718,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -698,7 +751,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostListResult"]: + ) -> Iterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -713,13 +766,16 @@ def list_by_host_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -729,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -741,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_images_operations.py index 4aa5419411ec..ea536c37fe11 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -155,9 +157,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +174,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -192,9 +195,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -205,18 +211,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +229,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -237,58 +244,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -300,11 +306,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -334,9 +342,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -357,37 +365,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -404,17 +422,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -426,11 +447,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -460,9 +483,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -483,37 +506,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -532,13 +565,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -547,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,20 +631,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -616,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -637,7 +686,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -651,13 +700,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -667,11 +719,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -707,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -722,9 +779,11 @@ def prepare_request(next_link=None): 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: @@ -733,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -772,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -781,13 +842,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -805,9 +871,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_log_analytics_operations.py index cfa474343f16..661d5af1054c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_operations.py index 96a34f89a3b1..3a1cef1d6333 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_proximity_placement_groups_operations.py index b20f861da0bf..24926739f8ef 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( include_colocation_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +172,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if include_colocation_status is not None: - _query_parameters['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -189,9 +192,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -235,51 +242,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -293,14 +296,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -312,11 +318,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -346,9 +354,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -362,14 +370,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -381,11 +392,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -424,13 +437,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -439,11 +455,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -467,7 +485,7 @@ def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -482,13 +500,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -498,11 +519,13 @@ def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +550,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -537,13 +560,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -551,9 +577,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -561,9 +589,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -601,7 +631,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -613,13 +643,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -628,9 +661,11 @@ def prepare_request(next_link=None): 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: @@ -639,9 +674,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_restore_point_collections_operations.py index 2ca0f2d2e7f0..9c87f64325dc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_restore_point_collections_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_restore_point_collections_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request( resource_group_name: str, restore_point_collection_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePointCollection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request( resource_group_name: str, restore_point_collection_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePointCollectionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( restore_point_collection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -161,9 +164,12 @@ def build_get_request( expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections") # pylint: disable=line-too-long path_format_arguments = { @@ -211,18 +218,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +236,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/restorePointCollections") path_format_arguments = { @@ -243,51 +251,47 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class RestorePointCollectionsOperations(object): - """RestorePointCollectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RestorePointCollectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollection", + parameters: _models.RestorePointCollection, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. @@ -304,14 +308,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollection') @@ -323,11 +330,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,9 +367,9 @@ def update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollectionUpdate", + parameters: _models.RestorePointCollectionUpdate, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. @@ -374,14 +383,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollectionUpdate') @@ -393,11 +405,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -425,13 +439,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -440,11 +457,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_name=restore_point_collection_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -487,20 +506,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -510,8 +534,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -531,7 +561,7 @@ def get( restore_point_collection_name: str, expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to get the restore point collection. :param resource_group_name: The name of the resource group. @@ -546,13 +576,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] request = build_get_request( @@ -562,11 +595,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,7 +628,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.RestorePointCollectionListResult"]: + ) -> Iterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in a resource group. :param resource_group_name: The name of the resource group. @@ -605,13 +640,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -620,9 +658,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -631,9 +671,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -671,7 +713,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.RestorePointCollectionListResult"]: + ) -> Iterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in the subscription. Use nextLink property in the response to get the next page of restore point collections. Do this till nextLink is not null to fetch all the restore point collections. @@ -683,13 +725,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -697,9 +742,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -707,9 +754,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_restore_points_operations.py index d7bad2d9ce1a..04395b4fd562 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_restore_points_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_restore_points_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_request_initial( restore_point_collection_name: str, restore_point_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePoint] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,9 +82,12 @@ def build_delete_request_initial( restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -96,18 +100,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -119,9 +121,12 @@ def build_get_request( restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,59 +139,58 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class RestorePointsOperations(object): - """RestorePointsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`restore_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_initial( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> "_models.RestorePoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] + ) -> _models.RestorePoint: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] _json = self._serialize.body(parameters, 'RestorePoint') @@ -199,11 +203,13 @@ def _create_initial( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -230,9 +236,9 @@ def begin_create( resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> LROPoller["_models.RestorePoint"]: + ) -> LROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. @@ -257,17 +263,20 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.RestorePoint] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] 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, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, @@ -275,20 +284,27 @@ def begin_create( 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('RestorePoint', 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( @@ -308,13 +324,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -324,11 +343,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_name=restore_point_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -373,21 +394,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -397,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -418,7 +450,7 @@ def get( restore_point_collection_name: str, restore_point_name: str, **kwargs: Any - ) -> "_models.RestorePoint": + ) -> _models.RestorePoint: """The operation to get the restore point. :param resource_group_name: The name of the resource group. @@ -432,13 +464,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] request = build_get_request( @@ -448,11 +483,13 @@ def get( restore_point_name=restore_point_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_ssh_public_keys_operations.py index ff4988ce48f5..5943153f13be 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_ssh_public_keys_operations.py @@ -16,12 +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 .. 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,9 +31,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") path_format_arguments = { @@ -43,18 +46,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -64,9 +65,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys") # pylint: disable=line-too-long path_format_arguments = { @@ -77,18 +81,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -98,14 +100,17 @@ def build_create_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -117,20 +122,18 @@ def build_create_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -142,14 +145,17 @@ def build_update_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyUpdateResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -161,20 +167,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -187,8 +191,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -200,13 +205,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -217,9 +221,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -231,18 +238,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -253,9 +258,12 @@ def build_generate_key_pair_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair") # pylint: disable=line-too-long path_format_arguments = { @@ -267,48 +275,44 @@ def build_generate_key_pair_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class SshPublicKeysOperations(object): - """SshPublicKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -319,13 +323,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -333,9 +340,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -343,9 +352,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -383,7 +394,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -396,13 +407,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -411,9 +425,11 @@ def prepare_request(next_link=None): 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: @@ -422,9 +438,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -462,9 +480,9 @@ def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -478,14 +496,17 @@ def create( :rtype: ~azure.mgmt.compute.v2021_03_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -497,11 +518,13 @@ def create( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -531,9 +554,9 @@ def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -547,14 +570,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_03_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -566,11 +592,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -609,13 +637,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -624,11 +655,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -651,7 +684,7 @@ def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -663,13 +696,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -678,11 +714,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -709,7 +747,7 @@ def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -723,13 +761,16 @@ def generate_key_pair( :rtype: ~azure.mgmt.compute.v2021_03_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -738,11 +779,13 @@ def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_usage_operations.py index 6d7661fdfc9d..6c8be8f4d6b2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_extension_images_operations.py index 0263d9d1ddaf..c043b2587e80 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_extensions_operations.py index 43763837b85b..2919b8a1128f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,8 +129,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -141,13 +144,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -161,9 +163,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -176,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -202,9 +205,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -216,61 +222,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -283,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -318,9 +325,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -347,17 +354,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -365,20 +375,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -396,17 +413,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -419,11 +439,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,9 +472,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -479,17 +501,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -497,20 +522,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -530,13 +562,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -546,11 +581,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,21 +632,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -619,8 +661,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -641,7 +689,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -657,13 +705,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -674,11 +725,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -706,7 +759,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -720,13 +773,16 @@ def list( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -736,11 +792,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_images_edge_zone_operations.py index f46d2e702768..2ee2bbc83b02 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_images_edge_zone_operations.py @@ -15,6 +15,7 @@ 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 @@ -35,9 +36,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,18 +57,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -82,9 +84,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -99,24 +104,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -128,9 +131,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +149,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -165,9 +169,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -179,18 +186,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +208,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -219,42 +227,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesEdgeZoneOperations(object): - """VirtualMachineImagesEdgeZoneOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesEdgeZoneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -266,7 +270,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. @@ -286,13 +290,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -305,11 +312,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -343,7 +352,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. @@ -370,13 +379,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -391,11 +403,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -424,7 +438,7 @@ def list_offers( edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. @@ -439,13 +453,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -455,11 +472,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -487,7 +506,7 @@ def list_publishers( location: str, edge_zone: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. @@ -499,13 +518,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -514,11 +536,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -548,7 +572,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. @@ -565,13 +589,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -582,11 +609,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_images_operations.py index de780c93101a..b58f0815f19c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_run_commands_operations.py index e3d9ba443688..c25ee34a134d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -69,9 +70,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -83,18 +87,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -105,14 +107,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -125,20 +130,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -151,14 +154,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,20 +177,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -198,9 +202,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -213,18 +220,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -238,9 +243,12 @@ def build_get_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -253,20 +261,18 @@ def build_get_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -279,9 +285,12 @@ def build_list_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -293,51 +302,47 @@ def build_list_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -349,13 +354,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +372,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -375,9 +385,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -416,7 +428,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -428,13 +440,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -443,11 +458,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -473,18 +490,21 @@ def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -497,11 +517,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,11 +554,11 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -548,7 +570,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -565,16 +587,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -582,20 +607,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -613,18 +645,21 @@ def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -637,11 +672,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -668,11 +705,11 @@ def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -683,7 +720,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -700,16 +737,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -717,20 +757,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -750,13 +797,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -766,11 +816,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,21 +867,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -839,8 +896,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -861,7 +924,7 @@ def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -877,13 +940,16 @@ def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -894,11 +960,13 @@ def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -927,7 +995,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -943,13 +1011,16 @@ def list_by_virtual_machine( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -960,9 +1031,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -973,9 +1046,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_extensions_operations.py index e12e960d23ec..5aac695abc28 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -345,17 +352,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -363,20 +373,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -394,17 +411,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -417,11 +437,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +474,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -481,17 +503,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -499,20 +524,27 @@ def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -532,13 +564,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -548,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -597,21 +634,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -621,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -643,7 +691,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -659,13 +707,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -676,11 +727,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -707,7 +760,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -721,13 +774,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -737,9 +793,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -749,9 +807,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 9af7b2786d9f..e188b95aa0a4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,8 +34,9 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -46,13 +48,12 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -63,8 +64,9 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -76,13 +78,12 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -93,8 +94,9 @@ def build_start_extension_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -106,13 +108,12 @@ def build_start_extension_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -123,9 +124,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -137,42 +141,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -180,13 +180,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -195,11 +198,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,20 +246,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -264,8 +274,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -284,13 +300,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -299,11 +318,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,20 +368,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -370,8 +396,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -390,13 +422,16 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -405,11 +440,13 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -453,20 +490,25 @@ def begin_start_extension_upgrade( # pylint: disable=inconsistent-return-statem :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_extension_upgrade_initial( + raw_result = self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -476,8 +518,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -496,7 +544,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -508,13 +556,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -523,11 +574,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py index 69a0afe6e725..f0dd73de74da 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -56,20 +59,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -83,14 +84,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -104,20 +108,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -132,9 +134,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -148,18 +153,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -174,9 +177,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -190,20 +196,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -217,9 +221,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -232,44 +239,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMExtensionsOperations(object): - """VirtualMachineScaleSetVMExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -277,17 +280,20 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -301,11 +307,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -368,17 +376,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -387,20 +398,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -419,17 +437,20 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -443,11 +464,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -475,9 +498,9 @@ def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -506,17 +529,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -525,20 +551,27 @@ def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -559,13 +592,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -576,11 +612,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -628,22 +666,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -653,8 +696,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -676,7 +725,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -694,13 +743,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -712,11 +764,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -746,7 +800,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -762,13 +816,16 @@ def list( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -779,11 +836,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index 10a7f671f0d8..05ab909ab6e1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -133,9 +135,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -149,18 +154,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -175,9 +178,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -191,20 +197,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -218,9 +222,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -233,44 +240,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMRunCommandsOperations(object): - """VirtualMachineScaleSetVMRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -278,18 +281,21 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -303,11 +309,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -339,11 +347,11 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -356,7 +364,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -373,16 +381,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -423,18 +441,21 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,11 +503,11 @@ def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -497,7 +520,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -514,16 +537,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -532,20 +558,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -566,13 +599,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -583,11 +619,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,22 +673,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -660,8 +703,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -683,7 +732,7 @@ def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -701,13 +750,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_request( @@ -719,11 +771,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -753,7 +807,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -771,13 +825,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -789,9 +846,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -803,9 +862,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_vms_operations.py index 12fc4454d115..5650b8f119a5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,13 +35,15 @@ def build_reimage_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -54,19 +56,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,8 +80,9 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -94,13 +95,12 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -112,8 +112,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -126,13 +127,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -143,14 +143,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -163,20 +166,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -192,8 +193,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -206,15 +208,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -228,9 +229,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -243,20 +247,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -268,9 +270,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -283,18 +288,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -309,9 +312,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -323,24 +329,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -354,8 +358,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -368,15 +373,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -388,8 +392,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -402,13 +407,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -420,8 +424,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -434,13 +439,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -452,8 +456,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -466,13 +471,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -486,9 +490,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -501,20 +508,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -526,8 +531,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -540,13 +546,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -558,8 +563,9 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -572,13 +578,12 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -589,14 +594,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -609,63 +617,62 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -681,11 +688,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -708,7 +717,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -735,17 +744,20 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -753,6 +765,8 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -762,8 +776,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -783,13 +803,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -799,11 +822,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -849,21 +874,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -873,8 +903,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -894,13 +930,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -910,11 +949,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -961,21 +1002,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -985,8 +1031,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1004,17 +1056,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -1027,11 +1082,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1062,9 +1119,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1090,17 +1147,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1108,20 +1168,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1142,13 +1209,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1159,11 +1229,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1212,22 +1284,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1237,8 +1314,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1259,7 +1342,7 @@ def get( instance_id: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1277,13 +1360,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1294,11 +1380,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1326,7 +1414,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1340,13 +1428,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1356,11 +1447,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1390,7 +1483,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1414,13 +1507,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1433,9 +1529,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1448,9 +1546,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1491,13 +1591,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1508,11 +1611,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1564,22 +1669,27 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1589,8 +1699,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1610,13 +1726,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1626,11 +1745,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1675,21 +1796,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1699,8 +1825,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1720,13 +1852,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1736,11 +1871,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1785,21 +1922,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1809,8 +1951,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1830,13 +1978,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1846,11 +1997,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1896,21 +2049,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1920,8 +2078,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1942,7 +2106,7 @@ def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -1961,13 +2125,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1978,11 +2145,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2011,13 +2180,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2027,11 +2199,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2076,21 +2250,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2100,8 +2279,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2135,13 +2320,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2151,11 +2339,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2177,18 +2367,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2201,11 +2394,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2234,11 +2429,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2249,7 +2444,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_03_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2265,16 +2460,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2282,20 +2480,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_sets_operations.py index 5943286fefaa..ad503216b25f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -159,8 +162,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,15 +176,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -193,9 +196,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -207,20 +213,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -230,13 +234,15 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -248,19 +254,17 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -272,14 +276,16 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -291,21 +297,19 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -318,9 +322,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -332,18 +339,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -353,9 +358,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -366,18 +374,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -386,9 +392,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -398,18 +407,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -420,9 +427,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -434,18 +444,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -456,9 +464,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -470,18 +481,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -491,14 +500,16 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -510,21 +521,19 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -536,13 +545,15 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -554,19 +565,17 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -578,13 +587,15 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -596,19 +607,17 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -620,13 +629,15 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -638,19 +649,17 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -662,13 +671,15 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -680,19 +691,17 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -704,13 +713,15 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -722,19 +733,17 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -746,13 +755,15 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -764,19 +775,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -788,13 +797,15 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -806,19 +817,17 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -833,9 +842,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( platform_update_domain: int, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -847,19 +859,17 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -869,13 +879,15 @@ def build_convert_to_single_placement_group_request( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VMScaleSetConvertToSinglePlacementGroupInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup") # pylint: disable=line-too-long path_format_arguments = { @@ -887,19 +899,17 @@ def build_convert_to_single_placement_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -911,13 +921,15 @@ def build_set_orchestration_service_state_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.OrchestrationServiceStateInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState") # pylint: disable=line-too-long path_format_arguments = { @@ -929,52 +941,48 @@ def build_set_orchestration_service_state_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. @@ -986,13 +994,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1001,9 +1012,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -1012,9 +1025,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1052,17 +1067,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -1074,11 +1092,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1108,9 +1128,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1133,37 +1153,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1180,17 +1210,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -1202,11 +1235,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1232,9 +1267,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1257,37 +1292,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1307,13 +1352,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1323,11 +1371,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1373,21 +1423,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1397,8 +1452,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1418,7 +1479,7 @@ def get( vm_scale_set_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1434,13 +1495,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1450,11 +1514,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1479,17 +1545,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1504,11 +1573,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1530,7 +1601,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1557,23 +1628,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1583,8 +1659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1601,18 +1683,21 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1625,11 +1710,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements json=_json, force_deletion=force_deletion, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1651,7 +1738,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: @@ -1679,17 +1766,20 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, @@ -1697,6 +1787,8 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1706,8 +1798,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1726,7 +1824,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1738,13 +1836,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1753,11 +1854,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1783,7 +1886,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1795,13 +1898,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1810,9 +1916,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1821,9 +1929,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1860,7 +1970,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1872,13 +1982,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1886,9 +1999,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1896,9 +2011,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1937,7 +2054,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1952,13 +2069,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1968,9 +2088,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1980,9 +2102,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2021,7 +2145,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -2035,13 +2159,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2051,9 +2178,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2063,9 +2192,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2103,17 +2234,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2129,11 +2263,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2156,7 +2292,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -2187,17 +2323,20 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -2205,6 +2344,8 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2214,8 +2355,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2232,17 +2379,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2257,11 +2407,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2283,7 +2435,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2308,23 +2460,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2334,8 +2491,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2352,17 +2515,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2377,11 +2543,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2403,7 +2571,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2428,23 +2596,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2454,8 +2627,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2472,17 +2651,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2497,11 +2679,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2523,7 +2707,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2549,23 +2733,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2575,8 +2764,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2593,17 +2788,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2618,11 +2816,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2644,7 +2844,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2672,23 +2872,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2698,8 +2903,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2716,17 +2927,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2738,11 +2952,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2764,7 +2980,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2788,23 +3004,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2814,8 +3035,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2832,17 +3059,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -2857,11 +3087,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2883,7 +3115,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -2909,23 +3141,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2935,8 +3172,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2953,17 +3196,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2978,11 +3224,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3004,7 +3252,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -3030,23 +3278,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -3056,8 +3309,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -3077,7 +3336,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -3093,13 +3352,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -3109,11 +3371,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3139,7 +3403,7 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -3156,14 +3420,17 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st :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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -3175,11 +3442,13 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3200,17 +3469,20 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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(parameters, 'OrchestrationServiceStateInput') @@ -3222,11 +3494,13 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3248,7 +3522,7 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> LROPoller[None]: """Changes ServiceState property for a given service. @@ -3271,23 +3545,28 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._set_orchestration_service_state_initial( + raw_result = self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -3297,8 +3576,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_sizes_operations.py index 4e9a3fa1075c..adbfae888fa3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -99,13 +99,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machines_operations.py index d18ff885fd58..9c419b2ea3aa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_03_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -203,8 +207,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -216,15 +221,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -237,9 +241,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -251,20 +258,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -275,9 +280,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -289,18 +297,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -311,8 +317,9 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -324,13 +331,12 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -341,8 +347,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -354,13 +361,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -371,8 +377,9 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -384,13 +391,12 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -400,9 +406,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -413,18 +422,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -435,9 +442,12 @@ def build_list_all_request( status_only: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -447,20 +457,18 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 status_only is not None: - _query_parameters['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') + _params['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -471,9 +479,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -485,18 +496,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -509,8 +518,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -522,15 +532,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -541,9 +550,12 @@ def build_reapply_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply") # pylint: disable=line-too-long path_format_arguments = { @@ -555,18 +567,16 @@ def build_reapply_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -577,8 +587,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -590,13 +601,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -607,8 +617,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -620,13 +631,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -637,8 +647,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -650,13 +661,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -666,13 +676,15 @@ def build_reimage_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -684,19 +696,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -711,9 +721,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -725,20 +738,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -749,8 +760,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -762,13 +774,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -779,8 +790,9 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -792,13 +804,12 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -809,9 +820,12 @@ def build_assess_patches_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -823,18 +837,16 @@ def build_assess_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -844,14 +856,17 @@ def build_install_patches_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineInstallPatchesParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -863,20 +878,18 @@ def build_install_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -888,14 +901,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -907,53 +923,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2021_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_03_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -965,13 +977,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -980,9 +995,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -991,9 +1008,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1030,17 +1049,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -1052,11 +1074,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1084,9 +1108,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -1110,37 +1134,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -1157,17 +1191,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -1179,11 +1216,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1213,9 +1252,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -1238,37 +1277,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1285,17 +1334,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1307,11 +1359,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1337,9 +1391,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1361,37 +1415,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1411,13 +1475,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1427,11 +1494,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1477,21 +1546,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1501,8 +1575,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1522,7 +1602,7 @@ def get( vm_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1540,13 +1620,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1556,11 +1639,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1587,7 +1672,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1599,13 +1684,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2021_03_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1614,11 +1702,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1645,13 +1735,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1660,11 +1753,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1707,20 +1802,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1730,8 +1830,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1750,13 +1856,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -1765,11 +1874,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1812,20 +1923,25 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1835,8 +1951,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1872,13 +1994,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1887,11 +2012,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1913,7 +2040,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1926,13 +2053,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1941,9 +2071,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1952,9 +2084,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1992,7 +2126,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -2006,13 +2140,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2021,9 +2158,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2032,9 +2171,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2073,7 +2214,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -2088,13 +2229,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2104,9 +2248,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2116,9 +2262,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2158,13 +2306,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -2174,11 +2325,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2226,21 +2379,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2250,8 +2408,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2270,13 +2434,16 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -2285,11 +2452,13 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2331,20 +2500,25 @@ def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._reapply_initial( + raw_result = self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2354,8 +2528,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2374,13 +2554,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2389,11 +2572,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2435,20 +2620,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2458,8 +2648,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2478,13 +2674,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2493,11 +2692,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2539,20 +2740,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2562,8 +2768,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2582,13 +2794,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2597,11 +2812,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2643,20 +2860,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2666,8 +2888,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2684,17 +2912,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -2709,11 +2940,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2735,7 +2968,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -2759,23 +2992,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -2785,8 +3023,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2806,7 +3050,7 @@ def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -2822,13 +3066,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_03_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -2838,11 +3085,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2870,13 +3119,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2885,11 +3137,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2931,20 +3185,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-03-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2954,8 +3213,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2986,13 +3251,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -3001,11 +3269,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3027,14 +3297,17 @@ def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -3043,11 +3316,13 @@ def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3076,7 +3351,7 @@ def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -3097,34 +3372,44 @@ def begin_assess_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -3141,17 +3426,20 @@ def _install_patches_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineInstallPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineInstallPatchesResult"]] + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # 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.VirtualMachineInstallPatchesResult]] _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') @@ -3163,11 +3451,13 @@ def _install_patches_initial( content_type=content_type, json=_json, template_url=self._install_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3195,9 +3485,9 @@ def begin_install_patches( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineInstallPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. @@ -3221,37 +3511,47 @@ def begin_install_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.VirtualMachineInstallPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstallPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstallPatchesResult"] 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._install_patches_initial( + raw_result = self._install_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineInstallPatchesResult', 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( @@ -3268,18 +3568,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -3291,11 +3594,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3323,11 +3628,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -3336,7 +3641,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_03_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -3352,36 +3657,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_03_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/_compute_management_client.py index 4ca35de62b8c..894d04f279c9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/_compute_management_client.py @@ -139,37 +139,99 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_point_collections = RestorePointCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservation_groups = CapacityReservationGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservations = CapacityReservationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_restore_point = DiskRestorePointOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_point_collections = RestorePointCollectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_points = RestorePointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservations = CapacityReservationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/_compute_management_client.py index 2998d9edfb41..5f233fe49de7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/_compute_management_client.py @@ -141,37 +141,99 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_point_collections = RestorePointCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservation_groups = CapacityReservationGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservations = CapacityReservationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_restore_point = DiskRestorePointOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_point_collections = RestorePointCollectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_points = RestorePointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservations = CapacityReservationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/__init__.py index 431c2df28db4..c782a583e181 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/__init__.py @@ -38,6 +38,9 @@ from ._disk_accesses_operations import DiskAccessesOperations from ._disk_restore_point_operations import DiskRestorePointOperations +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', 'AvailabilitySetsOperations', @@ -71,3 +74,5 @@ 'DiskAccessesOperations', 'DiskRestorePointOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_availability_sets_operations.py index 7206bc42302c..a0e9bb970c0c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_capacity_reservation_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_capacity_reservation_groups_operations.py index dbd6000abdb8..c5f9299b8d26 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_capacity_reservation_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_capacity_reservation_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CapacityReservationGroupsOperations: - """CapacityReservationGroupsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroup", + parameters: _models.CapacityReservationGroup, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details. @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroupUpdate", + parameters: _models.CapacityReservationGroupUpdate, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. @@ -138,14 +142,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroupUpdate') @@ -157,11 +164,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -203,13 +212,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -218,11 +230,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,7 +260,7 @@ async def get( capacity_reservation_group_name: str, expand: Optional[Union[str, "_models.CapacityReservationGroupInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation that retrieves information about a capacity reservation group. :param resource_group_name: The name of the resource group. @@ -264,13 +278,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.CapacityReservationGroup] request = build_get_request( @@ -280,11 +297,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationGroupListResult"]: + ) -> AsyncIterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -329,13 +348,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -345,9 +367,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, 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: @@ -357,9 +381,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 +423,7 @@ def list_by_subscription( self, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationGroupListResult"]: + ) -> AsyncIterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -413,13 +439,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -428,9 +457,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -439,9 +470,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_capacity_reservations_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_capacity_reservations_operations.py index 7e642c4b63e3..99f02c223bc6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_capacity_reservations_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_capacity_reservations_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CapacityReservationsOperations: - """CapacityReservationsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`capacity_reservations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> "_models.CapacityReservation": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] + ) -> _models.CapacityReservation: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.CapacityReservation] _json = self._serialize.body(parameters, 'CapacityReservation') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> AsyncLROPoller["_models.CapacityReservation"]: + ) -> AsyncLROPoller[_models.CapacityReservation]: """The operation to create or update a capacity reservation. Please note some properties can be set only during capacity reservation creation. Please refer to https://aka.ms/CapacityReservation for more details. @@ -139,17 +143,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -157,20 +164,27 @@ async def begin_create_or_update( 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('CapacityReservation', 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( @@ -188,17 +202,20 @@ async def _update_initial( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> Optional["_models.CapacityReservation"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CapacityReservation"]] + ) -> Optional[_models.CapacityReservation]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.CapacityReservation]] _json = self._serialize.body(parameters, 'CapacityReservationUpdate') @@ -211,11 +228,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -244,9 +263,9 @@ async def begin_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.CapacityReservation"]: + ) -> AsyncLROPoller[_models.CapacityReservation]: """The operation to update a capacity reservation. :param resource_group_name: The name of the resource group. @@ -271,17 +290,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -289,20 +311,27 @@ async def begin_update( 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('CapacityReservation', 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( @@ -322,13 +351,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements capacity_reservation_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -338,11 +370,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -389,21 +423,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -413,8 +452,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -435,7 +480,7 @@ async def get( capacity_reservation_name: str, expand: Optional[Union[str, "_models.CapacityReservationInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservation": + ) -> _models.CapacityReservation: """The operation that retrieves information about the capacity reservation. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.CapacityReservation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.CapacityReservation] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list_by_capacity_reservation_group( resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationListResult"]: + ) -> AsyncIterable[_models.CapacityReservationListResult]: """Lists all of the capacity reservations in the specified capacity reservation group. Use the nextLink property in the response to get the next page of capacity reservations. @@ -517,13 +567,16 @@ def list_by_capacity_reservation_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.CapacityReservationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -533,9 +586,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_capacity_reservation_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: @@ -545,9 +600,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_dedicated_host_groups_operations.py index 0d835d81ae6b..4af28d7b4900 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_dedicated_host_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostGroupsOperations: - """DedicatedHostGroupsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -137,14 +141,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -156,11 +163,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -199,13 +208,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,11 +226,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +256,7 @@ async def get( host_group_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -258,13 +272,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.DedicatedHostGroup] request = build_get_request( @@ -274,11 +291,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +323,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -317,13 +336,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -332,9 +354,11 @@ def prepare_request(next_link=None): 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: @@ -343,9 +367,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -382,7 +408,7 @@ async def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -393,13 +419,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -407,9 +436,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -417,9 +448,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_dedicated_hosts_operations.py index d143925a8426..7b0c2ae866b7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostsOperations: - """DedicatedHostsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('DedicatedHost', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -267,17 +286,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -285,20 +307,27 @@ async def begin_update( 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('DedicatedHost', 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( @@ -318,13 +347,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -334,11 +366,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,21 +417,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -407,8 +446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -429,7 +474,7 @@ async def get( host_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.DedicatedHost] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -495,7 +545,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostListResult"]: + ) -> AsyncIterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -510,13 +560,16 @@ def list_by_host_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -526,9 +579,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -538,9 +593,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disk_accesses_operations.py index 2882235a4b6a..59101a9e3935 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskAccessesOperations: - """DiskAccessesOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -340,11 +372,13 @@ async def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -626,7 +690,7 @@ async def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -640,13 +704,16 @@ async def get_private_link_resources( :rtype: ~azure.mgmt.compute.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', "2021-04-01") # 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.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -655,11 +722,13 @@ async def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -685,17 +754,20 @@ async def _update_a_private_endpoint_connection_initial( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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(private_endpoint_connection, 'PrivateEndpointConnection') @@ -708,11 +780,13 @@ async def _update_a_private_endpoint_connection_initial( content_type=content_type, json=_json, template_url=self._update_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -743,9 +817,9 @@ async def begin_update_a_private_endpoint_connection( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection under disk access resource, this can't be used to create a new private endpoint connection. @@ -775,17 +849,20 @@ async def begin_update_a_private_endpoint_connection( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_a_private_endpoint_connection_initial( + raw_result = await self._update_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -793,20 +870,27 @@ async def begin_update_a_private_endpoint_connection( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -826,7 +910,7 @@ async def get_a_private_endpoint_connection( disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about a private endpoint connection under a disk access resource. :param resource_group_name: The name of the resource group. @@ -842,13 +926,16 @@ async def get_a_private_endpoint_connection( :rtype: ~azure.mgmt.compute.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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_a_private_endpoint_connection_request( @@ -858,11 +945,13 @@ async def get_a_private_endpoint_connection( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get_a_private_endpoint_connection.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -890,13 +979,16 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inco private_endpoint_connection_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', "2021-04-01") # type: str + 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_a_private_endpoint_connection_request_initial( @@ -906,11 +998,13 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inco private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -957,21 +1051,26 @@ async def begin_delete_a_private_endpoint_connection( # pylint: disable=inconsi :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_a_private_endpoint_connection_initial( + raw_result = await self._delete_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -981,8 +1080,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1001,7 +1106,7 @@ def list_private_endpoint_connections( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List information about private endpoint connections under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1017,13 +1122,16 @@ def list_private_endpoint_connections( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - 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: @@ -1033,9 +1141,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=self.list_private_endpoint_connections.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1045,9 +1155,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disk_encryption_sets_operations.py index 16f86202c65f..215a66c8871d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskEncryptionSetsOperations: - """DiskEncryptionSetsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -238,9 +257,9 @@ async def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -266,37 +285,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -315,7 +344,7 @@ async def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -329,13 +358,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.DiskEncryptionSet] request = build_get_request( @@ -344,11 +376,13 @@ async def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -375,13 +409,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -390,11 +427,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,20 +477,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -461,8 +505,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -480,7 +530,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -492,13 +542,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -507,9 +560,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -518,9 +573,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -557,7 +614,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -567,13 +624,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -581,9 +641,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -591,9 +653,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -632,7 +696,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceUriList"]: + ) -> AsyncIterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -647,13 +711,16 @@ def list_associated_resources( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -663,9 +730,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_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,9 +744,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disk_restore_point_operations.py index 7e757f521661..691ae016fb22 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disk_restore_point_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskRestorePointOperations: - """DiskRestorePointOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -55,7 +54,7 @@ async def get( vm_restore_point_name: str, disk_restore_point_name: str, **kwargs: Any - ) -> "_models.DiskRestorePoint": + ) -> _models.DiskRestorePoint: """Get disk restorePoint resource. :param resource_group_name: The name of the resource group. @@ -73,13 +72,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DiskRestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePoint] request = build_get_request( @@ -90,11 +92,13 @@ async def get( disk_restore_point_name=disk_restore_point_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -122,7 +126,7 @@ def list_by_restore_point( restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskRestorePointList"]: + ) -> AsyncIterable[_models.DiskRestorePointList]: """Lists diskRestorePoints under a vmRestorePoint. :param resource_group_name: The name of the resource group. @@ -140,13 +144,16 @@ def list_by_restore_point( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskRestorePointList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePointList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePointList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -157,9 +164,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=self.list_by_restore_point.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -170,9 +179,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -211,17 +222,20 @@ async def _grant_access_initial( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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[Optional[_models.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -235,11 +249,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -269,9 +285,9 @@ async def begin_grant_access( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a diskRestorePoint. :param resource_group_name: The name of the resource group. @@ -300,17 +316,20 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, @@ -319,20 +338,27 @@ async def begin_grant_access( 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('AccessUri', 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( @@ -353,13 +379,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_restore_point_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -370,11 +399,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_restore_point_name=disk_restore_point_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -424,22 +455,27 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, disk_restore_point_name=disk_restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -449,8 +485,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disks_operations.py index 1e5c338a0408..1f2ade9cf288 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_images_operations.py index 80462b6f5d50..e3a52e1a5e9a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_log_analytics_operations.py index 1e23acce3788..0f66e13b5794 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_operations.py index 5f722c6ba4fc..80403b057d3d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_proximity_placement_groups_operations.py index b860ebb88b67..998d43664526 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,7 +254,7 @@ async def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -255,13 +269,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.ProximityPlacementGroup] request = build_get_request( @@ -271,11 +288,13 @@ async def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -300,7 +319,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -310,13 +329,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -324,9 +346,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -334,9 +358,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -374,7 +400,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -386,13 +412,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,9 +430,11 @@ def prepare_request(next_link=None): 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: @@ -412,9 +443,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_restore_point_collections_operations.py index 58f91d7b6938..57a1a7620960 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_restore_point_collections_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_restore_point_collections_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,35 +27,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RestorePointCollectionsOperations: - """RestorePointCollectionsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollection", + parameters: _models.RestorePointCollection, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. @@ -71,14 +70,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollection') @@ -90,11 +92,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,9 +128,9 @@ async def update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollectionUpdate", + parameters: _models.RestorePointCollectionUpdate, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. @@ -140,14 +144,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollectionUpdate') @@ -159,11 +166,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -190,13 +199,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_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', "2021-04-01") # type: str + 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_initial( @@ -205,11 +217,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_name=restore_point_collection_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -252,20 +266,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -275,8 +294,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -296,7 +321,7 @@ async def get( restore_point_collection_name: str, expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to get the restore point collection. :param resource_group_name: The name of the resource group. @@ -311,13 +336,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.RestorePointCollection] request = build_get_request( @@ -327,11 +355,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -357,7 +387,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.RestorePointCollectionListResult"]: + ) -> AsyncIterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in a resource group. :param resource_group_name: The name of the resource group. @@ -369,13 +399,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -384,9 +417,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -395,9 +430,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -434,7 +471,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.RestorePointCollectionListResult"]: + ) -> AsyncIterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in the subscription. Use nextLink property in the response to get the next page of restore point collections. Do this till nextLink is not null to fetch all the restore point collections. @@ -446,13 +483,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -460,9 +500,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -470,9 +512,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_restore_points_operations.py index 9c4aa554ebcd..1b06799ed66c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_restore_points_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_restore_points_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RestorePointsOperations: - """RestorePointsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`restore_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_initial( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> "_models.RestorePoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] + ) -> _models.RestorePoint: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.RestorePoint] _json = self._serialize.body(parameters, 'RestorePoint') @@ -73,11 +75,13 @@ async def _create_initial( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -104,9 +108,9 @@ async def begin_create( resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> AsyncLROPoller["_models.RestorePoint"]: + ) -> AsyncLROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. @@ -131,17 +135,20 @@ async def begin_create( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.RestorePoint] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.RestorePoint] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] 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, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, @@ -149,20 +156,27 @@ async def begin_create( 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('RestorePoint', 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( @@ -182,13 +196,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -198,11 +215,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_name=restore_point_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,21 +266,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -271,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -292,7 +322,7 @@ async def get( restore_point_collection_name: str, restore_point_name: str, **kwargs: Any - ) -> "_models.RestorePoint": + ) -> _models.RestorePoint: """The operation to get the restore point. :param resource_group_name: The name of the resource group. @@ -306,13 +336,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.RestorePoint] request = build_get_request( @@ -322,11 +355,13 @@ async def get( restore_point_name=restore_point_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_snapshots_operations.py index b3eb10d13bc3..49208a3426c2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_ssh_public_keys_operations.py index 19acb4a0cfb7..6227b2d9247f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_ssh_public_keys_operations.py @@ -15,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 @@ -24,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SshPublicKeysOperations: - """SshPublicKeysOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -60,13 +59,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -74,9 +76,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -84,9 +88,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +130,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -137,13 +143,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -152,9 +161,11 @@ def prepare_request(next_link=None): 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: @@ -163,9 +174,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -203,9 +216,9 @@ async def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -219,14 +232,17 @@ async def create( :rtype: ~azure.mgmt.compute.v2021_04_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -238,11 +254,13 @@ async def create( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -272,9 +290,9 @@ async def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -288,14 +306,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -307,11 +328,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -350,13 +373,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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', "2021-04-01") # type: str + 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( @@ -365,11 +391,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,7 +420,7 @@ async def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -404,13 +432,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.SshPublicKeyResource] request = build_get_request( @@ -419,11 +450,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,7 +483,7 @@ async def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -464,13 +497,16 @@ async def generate_key_pair( :rtype: ~azure.mgmt.compute.v2021_04_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -479,11 +515,13 @@ async def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_usage_operations.py index e2742b0f251e..775354aef88a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_extension_images_operations.py index 796726e6e7b9..0d5e38fe8ef9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_extensions_operations.py index c1f423aa313c..e929e346ef53 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2021-04-01") # type: str + 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_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_images_edge_zone_operations.py index d3b30c376f7c..71faf7ea6b4b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_images_edge_zone_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesEdgeZoneOperations: - """VirtualMachineImagesEdgeZoneOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +52,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. @@ -73,13 +72,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineImage] request = build_get_request( @@ -92,11 +94,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -129,7 +133,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. @@ -156,13 +160,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -177,11 +184,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -209,7 +218,7 @@ async def list_offers( edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. @@ -224,13 +233,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -240,11 +252,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -271,7 +285,7 @@ async def list_publishers( location: str, edge_zone: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. @@ -283,13 +297,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -298,11 +315,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -331,7 +350,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. @@ -348,13 +367,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -365,11 +387,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_images_operations.py index 512d8f105fdc..53de954c22d6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_run_commands_operations.py index 46466943b0cc..d7a88c1bd251 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -64,13 +63,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,7 +137,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -143,13 +149,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -158,11 +167,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,18 +199,21 @@ async def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -212,11 +226,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,11 +263,11 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -263,7 +279,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -280,16 +296,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -297,20 +316,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -328,18 +354,21 @@ async def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -352,11 +381,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,11 +414,11 @@ async def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -398,7 +429,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -415,16 +446,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -432,20 +466,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -465,13 +506,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -481,11 +525,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,21 +576,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -554,8 +605,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -576,7 +633,7 @@ async def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -592,13 +649,16 @@ async def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -609,11 +669,13 @@ async def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -641,7 +703,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -657,13 +719,16 @@ def list_by_virtual_machine( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -674,9 +739,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -687,9 +754,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index bc1d5a471c50..7821cf1f4ad1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -189,17 +203,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -212,11 +229,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -276,17 +295,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -294,20 +316,27 @@ async def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -327,13 +356,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -343,11 +375,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,21 +426,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -416,8 +455,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -438,7 +483,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineScaleSetExtension] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -516,13 +566,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -532,9 +585,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -544,9 +599,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index a285933498a3..f7c6d61e2643 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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', "2021-04-01") # type: str + 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_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,13 +292,16 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu vm_scale_set_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', "2021-04-01") # type: str + 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_start_extension_upgrade_request_initial( @@ -276,11 +310,13 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,20 +360,25 @@ async def begin_start_extension_upgrade( # pylint: disable=inconsistent-return- :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._start_extension_upgrade_initial( + raw_result = await self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -347,8 +388,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -367,7 +414,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -379,13 +426,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -394,11 +444,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py index d4271dce1513..24252c2d8192 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMExtensionsOperations: - """VirtualMachineScaleSetVMExtensionsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -51,17 +50,20 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -111,9 +115,9 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -161,20 +168,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -193,17 +207,20 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -217,11 +234,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -249,9 +268,9 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -280,17 +299,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -299,20 +321,27 @@ async def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -333,13 +362,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2021-04-01") # type: str + 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_initial( @@ -350,11 +382,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -402,22 +436,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -427,8 +466,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -450,7 +495,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -468,13 +513,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -486,11 +534,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -519,7 +569,7 @@ async def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -535,13 +585,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -552,11 +605,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index 4171bb0493dd..6ed5a762f1e7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMRunCommandsOperations: - """VirtualMachineScaleSetVMRunCommandsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,18 +52,21 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -78,11 +80,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -114,11 +118,11 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -131,7 +135,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -148,16 +152,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -166,20 +173,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -198,18 +212,21 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -223,11 +240,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,11 +274,11 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -272,7 +291,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -289,16 +308,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -307,20 +329,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -341,13 +370,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -358,11 +390,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -410,22 +444,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -435,8 +474,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -458,7 +503,7 @@ async def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -476,13 +521,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineRunCommand] request = build_get_request( @@ -494,11 +542,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +577,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -545,13 +595,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -563,9 +616,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -577,9 +632,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index e2c3f7124125..96c52fd6e376 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -78,11 +80,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -132,17 +136,20 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -150,6 +157,8 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,13 +195,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -196,11 +214,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,21 +266,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -270,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -291,13 +322,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-04-01") # type: str + 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_deallocate_request_initial( @@ -307,11 +341,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,21 +394,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -382,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -401,17 +448,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -424,11 +474,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,9 +511,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -487,17 +539,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -505,20 +560,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -539,13 +601,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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', "2021-04-01") # type: str + 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_initial( @@ -556,11 +621,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -609,22 +676,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -634,8 +706,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -656,7 +734,7 @@ async def get( instance_id: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -674,13 +752,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -691,11 +772,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -723,7 +806,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -737,13 +820,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -753,11 +839,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -787,7 +875,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -811,13 +899,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -830,9 +921,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -845,9 +938,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -888,13 +983,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2021-04-01") # type: str + 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_power_off_request_initial( @@ -905,11 +1003,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -961,22 +1061,27 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -986,8 +1091,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1007,13 +1118,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1023,11 +1137,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1072,21 +1188,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1096,8 +1217,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1117,13 +1244,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1133,11 +1263,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1182,21 +1314,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1206,8 +1343,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1227,13 +1370,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1243,11 +1389,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1293,21 +1441,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1317,8 +1470,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1339,7 +1498,7 @@ async def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -1358,13 +1517,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1375,11 +1537,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1407,13 +1571,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2021-04-01") # type: str + 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_perform_maintenance_request_initial( @@ -1423,11 +1590,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1472,21 +1641,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1496,8 +1670,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1531,13 +1711,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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', "2021-04-01") # type: str + 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_simulate_eviction_request( @@ -1547,11 +1730,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1573,18 +1758,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1597,11 +1785,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1630,11 +1820,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1645,7 +1835,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_04_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1662,16 +1852,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1679,20 +1872,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_sets_operations.py index 7dabca0368df..35fbed53808f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -151,11 +160,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -185,9 +196,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -210,37 +221,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -257,17 +278,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -279,11 +303,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +335,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -334,37 +360,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -384,13 +420,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -400,11 +439,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,21 +491,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -474,8 +520,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -495,7 +547,7 @@ async def get( vm_scale_set_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -511,13 +563,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineScaleSet] request = build_get_request( @@ -527,11 +582,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -556,17 +613,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -581,11 +641,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -607,7 +669,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -634,23 +696,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -660,8 +727,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -678,18 +751,21 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -702,11 +778,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat json=_json, force_deletion=force_deletion, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -728,7 +806,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: @@ -756,17 +834,20 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, @@ -774,6 +855,8 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -783,8 +866,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -803,7 +892,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -815,13 +904,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -830,11 +922,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -860,7 +954,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -872,13 +966,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -887,9 +984,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -898,9 +997,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -937,7 +1038,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -949,13 +1050,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -963,9 +1067,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -973,9 +1079,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1014,7 +1122,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1029,13 +1137,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1045,9 +1156,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1057,9 +1170,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1098,7 +1213,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1112,13 +1227,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1128,9 +1246,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1140,9 +1260,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1180,17 +1302,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1206,11 +1331,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1233,7 +1360,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1264,17 +1391,20 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -1282,6 +1412,8 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1291,8 +1423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1309,17 +1447,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1334,11 +1475,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1360,7 +1503,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1385,23 +1528,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1411,8 +1559,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1429,17 +1583,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1454,11 +1611,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1480,7 +1639,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1505,23 +1664,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1531,8 +1695,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1549,17 +1719,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1574,11 +1747,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1600,7 +1775,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1626,23 +1801,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1652,8 +1832,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1670,17 +1856,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1695,11 +1884,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1721,7 +1912,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1749,23 +1940,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1775,8 +1971,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1793,17 +1995,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1815,11 +2020,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1841,7 +2048,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1865,23 +2072,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1891,8 +2103,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1909,17 +2127,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -1934,11 +2155,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1960,7 +2183,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -1986,23 +2209,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2012,8 +2240,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2030,17 +2264,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2055,11 +2292,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2081,7 +2320,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2107,23 +2346,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2133,8 +2377,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2154,7 +2404,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2170,13 +2420,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2186,11 +2439,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2216,7 +2471,7 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -2233,14 +2488,17 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret :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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] _json = self._serialize.body(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -2252,11 +2510,13 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2277,17 +2537,20 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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(parameters, 'OrchestrationServiceStateInput') @@ -2299,11 +2562,13 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2325,7 +2590,7 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> AsyncLROPoller[None]: """Changes ServiceState property for a given service. @@ -2348,23 +2613,28 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + 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._set_orchestration_service_state_initial( + raw_result = await self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -2374,8 +2644,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_sizes_operations.py index b0c556d2b62b..47a0ba722d56 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machines_operations.py index 2521c653ef27..6413ec02dee7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.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.compute.v2021_04_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -338,37 +364,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -385,17 +421,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -407,11 +446,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -437,9 +478,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -462,37 +503,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -512,13 +563,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -528,11 +582,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -578,21 +634,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -602,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -623,7 +690,7 @@ async def get( vm_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. @@ -641,13 +708,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachine] request = build_get_request( @@ -657,11 +727,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -688,7 +760,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -700,13 +772,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -715,11 +790,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -746,13 +823,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -761,11 +841,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -808,20 +890,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -831,8 +918,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -851,13 +944,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -866,11 +962,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -913,20 +1011,25 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -936,8 +1039,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -973,13 +1082,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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', "2021-04-01") # type: str + 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_generalize_request( @@ -988,11 +1100,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1014,7 +1128,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1027,13 +1141,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1042,9 +1159,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1053,9 +1172,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1093,7 +1214,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1107,13 +1228,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1122,9 +1246,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1133,9 +1259,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1174,7 +1302,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1189,13 +1317,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1205,9 +1336,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1217,9 +1350,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1259,13 +1394,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1275,11 +1413,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1327,21 +1467,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1351,8 +1496,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1371,13 +1522,16 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-04-01") # type: str + 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_reapply_request_initial( @@ -1386,11 +1540,13 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1432,20 +1588,25 @@ async def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._reapply_initial( + raw_result = await self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1455,8 +1616,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1475,13 +1642,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-04-01") # type: str + 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_restart_request_initial( @@ -1490,11 +1660,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1536,20 +1708,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1559,8 +1736,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1579,13 +1762,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-04-01") # type: str + 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_start_request_initial( @@ -1594,11 +1780,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1640,20 +1828,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1663,8 +1856,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1683,13 +1882,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-04-01") # type: str + 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_redeploy_request_initial( @@ -1698,11 +1900,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1744,20 +1948,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1767,8 +1976,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1785,17 +2000,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -1810,11 +2028,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1836,7 +2056,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -1860,23 +2080,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -1886,8 +2111,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1907,7 +2138,7 @@ async def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -1923,13 +2154,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1939,11 +2173,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1970,13 +2206,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1985,11 +2224,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2031,20 +2272,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2054,8 +2300,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2086,13 +2338,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2101,11 +2356,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2127,14 +2384,17 @@ async def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -2143,11 +2403,13 @@ async def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2176,7 +2438,7 @@ async def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -2197,34 +2459,44 @@ async def begin_assess_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = await self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -2241,17 +2513,20 @@ async def _install_patches_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineInstallPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineInstallPatchesResult"]] + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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[Optional[_models.VirtualMachineInstallPatchesResult]] _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') @@ -2263,11 +2538,13 @@ async def _install_patches_initial( content_type=content_type, json=_json, template_url=self._install_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2295,9 +2572,9 @@ async def begin_install_patches( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineInstallPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. @@ -2321,37 +2598,47 @@ async def begin_install_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineInstallPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineInstallPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstallPatchesResult"] 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._install_patches_initial( + raw_result = await self._install_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineInstallPatchesResult', 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( @@ -2368,18 +2655,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2391,11 +2681,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2423,11 +2715,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2436,7 +2728,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_04_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2453,36 +2745,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_04_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/__init__.py index 74cd4db5462a..d2668acf9f9e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/__init__.py @@ -364,7 +364,9 @@ WindowsPatchAssessmentMode, WindowsVMGuestPatchMode, ) - +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__ = [ 'AccessUri', 'AdditionalCapabilities', @@ -721,3 +723,5 @@ 'WindowsPatchAssessmentMode', 'WindowsVMGuestPatchMode', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/_compute_management_client_enums.py index af963f3ae018..0cb064cc4cdc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/_compute_management_client_enums.py @@ -7,17 +7,16 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" WRITE = "Write" -class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. """ @@ -25,7 +24,7 @@ class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CLASSIC = "Classic" ALIGNED = "Aligned" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -36,15 +35,15 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class CapacityReservationGroupInstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CapacityReservationGroupInstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" -class CapacityReservationInstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CapacityReservationInstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" -class ConsistencyModeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConsistencyModeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the consistency mode for the restore point. Please refer to https://aka.ms/RestorePoints for more details. """ @@ -53,7 +52,7 @@ class ConsistencyModeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_SYSTEM_CONSISTENT = "FileSystemConsistent" APPLICATION_CONSISTENT = "ApplicationConsistent" -class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the software license type that will be applied to the VMs deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` @@ -64,20 +63,20 @@ class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" -class DeleteOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DeleteOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify what happens to the network interface when the VM is deleted """ DELETE = "Delete" DETACH = "Detach" -class DiffDiskOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk option for operating system disk. """ LOCAL = "Local" -class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskPlacement(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk placement for operating system disk. This property can be used by user in the request to choose the location i.e, cache disk or resource disk space for Ephemeral OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer @@ -90,7 +89,7 @@ class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CACHE_DISK = "CacheDisk" RESOURCE_DISK = "ResourceDisk" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -116,7 +115,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: complete only after all data has been copied from the source. COPY_START = "CopyStart" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -129,7 +128,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class DiskDeleteOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskDeleteOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the behavior of the managed disk when the VM gets deleted i.e whether the managed disk is deleted or detached. Supported values::code:`
`:code:`
` **Delete** If this value is used, the managed disk is deleted when VM gets deleted.:code:`
`:code:`
` **Detach** @@ -140,7 +139,7 @@ class DiskDeleteOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DELETE = "Delete" DETACH = "Detach" -class DiskDetachOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskDetachOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the detach behavior to be used while detaching a disk or which is already in the process of detachment from the virtual machine. Supported values: **ForceDetach**. :code:`
`:code:`
` detachOption: **ForceDetach** is applicable only for managed data @@ -154,7 +153,7 @@ class DiskDetachOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FORCE_DETACH = "ForceDetach" -class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted resources @@ -164,7 +163,7 @@ class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, SYSTEM_ASSIGNED = "SystemAssigned" NONE = "None" -class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -175,7 +174,7 @@ class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: of the keys is Customer managed and the other key is Platform managed. ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" -class DiskSecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskSecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the SecurityType of the VM. Applicable for OS disks only. """ @@ -183,7 +182,7 @@ class DiskSecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Module (vTPM). TRUSTED_LAUNCH = "TrustedLaunch" -class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible state of the disk. """ @@ -204,7 +203,7 @@ class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: A disk is created for upload and a write token has been issued for uploading to it. ACTIVE_UPLOAD = "ActiveUpload" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -225,7 +224,7 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: and dev/test that need storage resiliency against zone failures. STANDARD_SSD_ZRS = "StandardSSD_ZRS" -class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -239,7 +238,7 @@ class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the other key is Platform managed. ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" -class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExecutionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Script execution status. """ @@ -251,48 +250,48 @@ class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TIMED_OUT = "TimedOut" CANCELED = "Canceled" -class ExpandTypesForGetCapacityReservationGroups(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpandTypesForGetCapacityReservationGroups(str, Enum, metaclass=CaseInsensitiveEnumMeta): VIRTUAL_MACHINE_SCALE_SET_VMS_REF = "virtualMachineScaleSetVMs/$ref" VIRTUAL_MACHINES_REF = "virtualMachines/$ref" -class ExpandTypesForGetVMScaleSets(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpandTypesForGetVMScaleSets(str, Enum, metaclass=CaseInsensitiveEnumMeta): USER_DATA = "userData" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class HyperVGenerationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type associated with a resource """ V1 = "V1" V2 = "V2" -class HyperVGenerationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type """ V1 = "V1" V2 = "V2" -class InstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" USER_DATA = "userData" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -301,7 +300,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -310,7 +309,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class IPVersions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -319,7 +318,7 @@ class IPVersions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class LinuxPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinuxPatchAssessmentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` @@ -330,7 +329,7 @@ class LinuxPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class LinuxVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinuxVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's @@ -342,7 +341,7 @@ class LinuxVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -351,7 +350,7 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Policy for accessing the disk via network. """ @@ -362,14 +361,14 @@ class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The disk cannot be exported. DENY_ALL = "DenyAll" -class NetworkApiVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations """ TWO_THOUSAND_TWENTY11_01 = "2020-11-01" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ @@ -378,34 +377,34 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: Specialized image. Contains already provisioned OS Disk. SPECIALIZED = "Specialized" -class OperatingSystemType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class OrchestrationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the orchestration mode for the virtual machine scale set. """ UNIFORM = "Uniform" FLEXIBLE = "Flexible" -class OrchestrationServiceNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the service. """ AUTOMATIC_REPAIRS = "AutomaticRepairs" -class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current state of the service. """ @@ -413,21 +412,21 @@ class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enu RUNNING = "Running" SUSPENDED = "Suspended" -class OrchestrationServiceStateAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceStateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The action to be performed. """ RESUME = "Resume" SUSPEND = "Suspend" -class PatchAssessmentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchAssessmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the availability of a given patch. """ UNKNOWN = "Unknown" AVAILABLE = "Available" -class PatchInstallationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchInstallationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the patch after the installation operation completed. """ @@ -438,7 +437,7 @@ class PatchInstallationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) NOT_SELECTED = "NotSelected" PENDING = "Pending" -class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", or "CompletedWithWarnings." @@ -450,7 +449,7 @@ class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -459,7 +458,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. """ @@ -467,7 +466,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -475,7 +474,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -484,28 +483,28 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class PublicIPAddressSkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAddressSkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify public IP sku name """ BASIC = "Basic" STANDARD = "Standard" -class PublicIPAddressSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAddressSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify public IP sku tier """ REGIONAL = "Regional" GLOBAL_ENUM = "Global" -class PublicIPAllocationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify the public IP allocation type """ DYNAMIC = "Dynamic" STATIC = "Static" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Policy for controlling export on the disk. """ @@ -518,7 +517,7 @@ class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate. DISABLED = "Disabled" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -529,18 +528,18 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RestorePointCollectionExpandOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RestorePointCollectionExpandOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): RESTORE_POINTS = "restorePoints" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -549,7 +548,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not be enabled unless this property is set as TrustedLaunch. @@ -557,7 +556,7 @@ class SecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TRUSTED_LAUNCH = "TrustedLaunch" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -565,7 +564,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -576,7 +575,7 @@ class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E #: Standard zone redundant storage. STANDARD_ZRS = "Standard_ZRS" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -584,7 +583,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can only be used with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. StandardSSD_LRS uses @@ -602,7 +601,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PREMIUM_ZRS = "Premium_ZRS" STANDARD_SSD_ZRS = "StandardSSD_ZRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -614,7 +613,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -622,7 +621,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -631,14 +630,14 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for the Azure Spot VM/VMSS """ DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for a standalone virtual machine or the virtual machines in the scale set. :code:`
`:code:`
` 'Low' enum will be deprecated in the future, please use 'Spot' as the enum to deploy Azure Spot VM/VMSS. @@ -648,20 +647,20 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E LOW = "Low" SPOT = "Spot" -class VirtualMachineScaleSetScaleInRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "Default" OLDEST_VM = "OldestVM" NEWEST_VM = "NewestVM" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. :code:`
`:code:`
` The enum data type is currently deprecated and will be removed by December 23rd 2023. :code:`
`:code:`
` Recommended way to get the list of available sizes is using these APIs: @@ -843,20 +842,20 @@ class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) STANDARD_NV12 = "Standard_NV12" STANDARD_NV24 = "Standard_NV24" -class VmDiskTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VmDiskTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """VM disk types which are disallowed. """ NONE = "None" UNMANAGED = "Unmanaged" -class VMGuestPatchClassificationLinux(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchClassificationLinux(str, Enum, metaclass=CaseInsensitiveEnumMeta): CRITICAL = "Critical" SECURITY = "Security" OTHER = "Other" -class VMGuestPatchClassificationWindows(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchClassificationWindows(str, Enum, metaclass=CaseInsensitiveEnumMeta): CRITICAL = "Critical" SECURITY = "Security" @@ -867,7 +866,7 @@ class VMGuestPatchClassificationWindows(with_metaclass(CaseInsensitiveEnumMeta, TOOLS = "Tools" UPDATES = "Updates" -class VMGuestPatchRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the reboot requirements of the patch. """ @@ -876,7 +875,7 @@ class VMGuestPatchRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, En ALWAYS_REQUIRES_REBOOT = "AlwaysRequiresReboot" CAN_REQUEST_REBOOT = "CanRequestReboot" -class VMGuestPatchRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines when it is acceptable to reboot a VM during a software update operation. """ @@ -884,7 +883,7 @@ class VMGuestPatchRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enu NEVER = "Never" ALWAYS = "Always" -class VMGuestPatchRebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reboot state of the VM following completion of the operation. """ @@ -895,7 +894,7 @@ class VMGuestPatchRebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" COMPLETED = "Completed" -class WindowsPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WindowsPatchAssessmentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest patch assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` @@ -906,7 +905,7 @@ class WindowsPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, En IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class WindowsVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WindowsVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/_models_py3.py index 246a9b09de0e..9e204b3cb5ca 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -83,7 +85,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2021_04_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -104,7 +106,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -117,7 +119,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2021_04_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -185,8 +187,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -488,11 +490,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -550,7 +552,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -632,11 +634,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -672,8 +674,8 @@ class AvailablePatchSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_04_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -936,7 +938,7 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, **kwargs @@ -1106,7 +1108,7 @@ class CapacityReservationGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["CapacityReservationGroup"], + value: List["_models.CapacityReservationGroup"], next_link: Optional[str] = None, **kwargs ): @@ -1190,8 +1192,8 @@ class CapacityReservationInstanceView(msrest.serialization.Model): def __init__( self, *, - utilization_info: Optional["CapacityReservationUtilization"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + utilization_info: Optional["_models.CapacityReservationUtilization"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1233,8 +1235,8 @@ class CapacityReservationInstanceViewWithName(CapacityReservationInstanceView): def __init__( self, *, - utilization_info: Optional["CapacityReservationUtilization"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + utilization_info: Optional["_models.CapacityReservationUtilization"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1272,7 +1274,7 @@ class CapacityReservationListResult(msrest.serialization.Model): def __init__( self, *, - value: List["CapacityReservation"], + value: List["_models.CapacityReservation"], next_link: Optional[str] = None, **kwargs ): @@ -1305,7 +1307,7 @@ class CapacityReservationProfile(msrest.serialization.Model): def __init__( self, *, - capacity_reservation_group: Optional["SubResource"] = None, + capacity_reservation_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -1369,7 +1371,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -1506,9 +1508,8 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", - "CopyStart". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart". :vartype create_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskCreateOption :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -1557,10 +1558,10 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, - gallery_image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, + gallery_image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, upload_size_bytes: Optional[int] = None, @@ -1569,7 +1570,7 @@ def __init__( ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart". :paramtype create_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskCreateOption :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager @@ -1629,8 +1630,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1641,7 +1641,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1668,14 +1668,14 @@ class DataDisk(msrest.serialization.Model): force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. :code:`
`:code:`
` This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data - disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Possible - values include: "ForceDetach". + disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Known values + are: "ForceDetach". :vartype detach_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskDetachOptionTypes :ivar delete_option: Specifies whether data disk should be deleted or detached upon VM deletion.:code:`
`:code:`
` Possible values: :code:`
`:code:`
` **Delete** If this value is used, the data disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the data disk is retained after VM is deleted.:code:`
`:code:`
` - The default value is set to **detach**. Possible values include: "Delete", "Detach". + The default value is set to **detach**. Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskDeleteOptionTypes """ @@ -1707,17 +1707,17 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, to_be_detached: Optional[bool] = None, - detach_option: Optional[Union[str, "DiskDetachOptionTypes"]] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + detach_option: Optional[Union[str, "_models.DiskDetachOptionTypes"]] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ @@ -1736,8 +1736,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1748,7 +1747,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1767,14 +1766,14 @@ def __init__( force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. :code:`
`:code:`
` This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data - disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Possible - values include: "ForceDetach". + disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Known values + are: "ForceDetach". :paramtype detach_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskDetachOptionTypes :keyword delete_option: Specifies whether data disk should be deleted or detached upon VM deletion.:code:`
`:code:`
` Possible values: :code:`
`:code:`
` **Delete** If this value is used, the data disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the data disk is retained after VM is deleted.:code:`
`:code:`
` - The default value is set to **detach**. Possible values include: "Delete", "Detach". + The default value is set to **detach**. Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskDeleteOptionTypes """ super(DataDisk, self).__init__(**kwargs) @@ -1856,7 +1855,7 @@ class DedicatedHost(Resource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2021_04_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1901,11 +1900,11 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1926,7 +1925,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2021_04_01.models.DedicatedHostLicenseTypes """ @@ -1992,7 +1991,7 @@ class DedicatedHostAvailableCapacity(msrest.serialization.Model): def __init__( self, *, - allocatable_v_ms: Optional[List["DedicatedHostAllocatableVM"]] = None, + allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs ): """ @@ -2114,7 +2113,7 @@ class DedicatedHostGroupInstanceView(msrest.serialization.Model): def __init__( self, *, - hosts: Optional[List["DedicatedHostInstanceViewWithName"]] = None, + hosts: Optional[List["_models.DedicatedHostInstanceViewWithName"]] = None, **kwargs ): """ @@ -2150,7 +2149,7 @@ class DedicatedHostGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHostGroup"], + value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs ): @@ -2268,8 +2267,8 @@ class DedicatedHostInstanceView(msrest.serialization.Model): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2317,8 +2316,8 @@ class DedicatedHostInstanceViewWithName(DedicatedHostInstanceView): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2356,7 +2355,7 @@ class DedicatedHostListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHost"], + value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs ): @@ -2393,7 +2392,7 @@ class DedicatedHostUpdate(UpdateResource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2021_04_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -2430,7 +2429,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -2446,7 +2445,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2021_04_01.models.DedicatedHostLicenseTypes """ @@ -2478,7 +2477,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -2495,8 +2494,8 @@ def __init__( class DiffDiskSettings(msrest.serialization.Model): """Describes the parameters of ephemeral disk settings that can be specified for operating system disk. :code:`
`:code:`
` NOTE: The ephemeral disk settings can only be specified for managed disk. - :ivar option: Specifies the ephemeral disk settings for operating system disk. Possible values - include: "Local". + :ivar option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :vartype option: str or ~azure.mgmt.compute.v2021_04_01.models.DiffDiskOptions :ivar placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -2505,7 +2504,7 @@ class DiffDiskSettings(msrest.serialization.Model): Refer to VM size documentation for Windows VM at https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Possible values include: "CacheDisk", "ResourceDisk". + cache disk. Known values are: "CacheDisk", "ResourceDisk". :vartype placement: str or ~azure.mgmt.compute.v2021_04_01.models.DiffDiskPlacement """ @@ -2517,13 +2516,13 @@ class DiffDiskSettings(msrest.serialization.Model): def __init__( self, *, - option: Optional[Union[str, "DiffDiskOptions"]] = None, - placement: Optional[Union[str, "DiffDiskPlacement"]] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, + placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, **kwargs ): """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. Possible - values include: "Local". + :keyword option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :paramtype option: str or ~azure.mgmt.compute.v2021_04_01.models.DiffDiskOptions :keyword placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -2532,7 +2531,7 @@ def __init__( Refer to VM size documentation for Windows VM at https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Possible values include: "CacheDisk", "ResourceDisk". + cache disk. Known values are: "CacheDisk", "ResourceDisk". :paramtype placement: str or ~azure.mgmt.compute.v2021_04_01.models.DiffDiskPlacement """ super(DiffDiskSettings, self).__init__(**kwargs) @@ -2543,8 +2542,7 @@ def __init__( class DisallowedConfiguration(msrest.serialization.Model): """Specifies the disallowed configuration for a virtual machine image. - :ivar vm_disk_type: VM disk types which are disallowed. Possible values include: "None", - "Unmanaged". + :ivar vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :vartype vm_disk_type: str or ~azure.mgmt.compute.v2021_04_01.models.VmDiskTypes """ @@ -2555,11 +2553,11 @@ class DisallowedConfiguration(msrest.serialization.Model): def __init__( self, *, - vm_disk_type: Optional[Union[str, "VmDiskTypes"]] = None, + vm_disk_type: Optional[Union[str, "_models.VmDiskTypes"]] = None, **kwargs ): """ - :keyword vm_disk_type: VM disk types which are disallowed. Possible values include: "None", + :keyword vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :paramtype vm_disk_type: str or ~azure.mgmt.compute.v2021_04_01.models.VmDiskTypes """ @@ -2600,10 +2598,10 @@ class Disk(Resource): :vartype extended_location: ~azure.mgmt.compute.v2021_04_01.models.ExtendedLocation :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: @@ -2644,7 +2642,7 @@ class Disk(Resource): mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. :vartype disk_m_bps_read_only: long - :ivar disk_state: The state of the disk. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2021_04_01.models.DiskState :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed @@ -2656,8 +2654,8 @@ class Disk(Resource): :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should be set to a value greater than one for disks to allow attaching them to multiple VMs. :vartype share_info: list[~azure.mgmt.compute.v2021_04_01.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -2679,8 +2677,8 @@ class Disk(Resource): :ivar completion_percent: Percentage complete for the background copy when a resource is created via the CopyStart operation. :vartype completion_percent: float - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_04_01.models.PublicNetworkAccess """ @@ -2747,30 +2745,30 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlanAutoGenerated"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, - creation_data: Optional["CreationData"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlanAutoGenerated"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, supports_hibernation: Optional[bool] = None, - security_profile: Optional["DiskSecurityProfile"] = None, + security_profile: Optional["_models.DiskSecurityProfile"] = None, completion_percent: Optional[float] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, **kwargs ): """ @@ -2786,10 +2784,10 @@ def __init__( :keyword extended_location: The extended location where the disk will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2021_04_01.models.ExtendedLocation - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: @@ -2830,8 +2828,8 @@ def __init__( :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -2851,8 +2849,8 @@ def __init__( :keyword completion_percent: Percentage complete for the background copy when a resource is created via the CopyStart operation. :paramtype completion_percent: float - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_04_01.models.PublicNetworkAccess """ @@ -2949,7 +2947,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, **kwargs ): """ @@ -2992,7 +2990,7 @@ class DiskAccessList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskAccess"], + value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs ): @@ -3053,8 +3051,8 @@ class DiskEncryptionSet(Resource): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2021_04_01.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype encryption_type: str or ~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSetType :ivar active_key: The key vault key which is currently used by this disk encryption set. :vartype active_key: ~azure.mgmt.compute.v2021_04_01.models.KeyForDiskEncryptionSet @@ -3108,9 +3106,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyForDiskEncryptionSet"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, rotation_to_latest_key_version_enabled: Optional[bool] = None, **kwargs ): @@ -3122,8 +3120,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2021_04_01.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype encryption_type: str or ~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSetType :keyword active_key: The key vault key which is currently used by this disk encryption set. :paramtype active_key: ~azure.mgmt.compute.v2021_04_01.models.KeyForDiskEncryptionSet @@ -3166,7 +3164,7 @@ class DiskEncryptionSetList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskEncryptionSet"], + value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs ): @@ -3252,8 +3250,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -3280,8 +3278,8 @@ class DiskEncryptionSetUpdate(msrest.serialization.Model): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2021_04_01.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype encryption_type: str or ~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSetType :ivar active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and Snapshots. @@ -3303,9 +3301,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyForDiskEncryptionSet"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, rotation_to_latest_key_version_enabled: Optional[bool] = None, **kwargs ): @@ -3315,8 +3313,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2021_04_01.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype encryption_type: str or ~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSetType :keyword active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and Snapshots. @@ -3356,8 +3354,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -3400,7 +3398,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -3468,10 +3466,10 @@ class DiskRestorePoint(ProxyOnlyResource): :vartype time_created: ~datetime.datetime :ivar source_resource_id: arm id of source disk. :vartype source_resource_id: str - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. @@ -3488,12 +3486,12 @@ class DiskRestorePoint(ProxyOnlyResource): :vartype encryption: ~azure.mgmt.compute.v2021_04_01.models.Encryption :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. :vartype supports_hibernation: bool - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkAccessPolicy - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_04_01.models.PublicNetworkAccess :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -3538,19 +3536,19 @@ class DiskRestorePoint(ProxyOnlyResource): def __init__( self, *, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlanAutoGenerated"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlanAutoGenerated"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, supports_hibernation: Optional[bool] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, disk_access_id: Optional[str] = None, completion_percent: Optional[float] = None, **kwargs ): """ :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. @@ -3560,12 +3558,12 @@ def __init__( :paramtype supported_capabilities: ~azure.mgmt.compute.v2021_04_01.models.SupportedCapabilities :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. :paramtype supports_hibernation: bool - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkAccessPolicy - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_04_01.models.PublicNetworkAccess :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -3616,7 +3614,7 @@ class DiskRestorePointList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskRestorePoint"], + value: List["_models.DiskRestorePoint"], next_link: Optional[str] = None, **kwargs ): @@ -3635,8 +3633,8 @@ def __init__( class DiskSecurityProfile(msrest.serialization.Model): """Contains the security related information for the resource. - :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Possible values include: "TrustedLaunch". + :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. Known + values are: "TrustedLaunch". :vartype security_type: str or ~azure.mgmt.compute.v2021_04_01.models.DiskSecurityTypes """ @@ -3647,12 +3645,12 @@ class DiskSecurityProfile(msrest.serialization.Model): def __init__( self, *, - security_type: Optional[Union[str, "DiskSecurityTypes"]] = None, + security_type: Optional[Union[str, "_models.DiskSecurityTypes"]] = None, **kwargs ): """ :keyword security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Possible values include: "TrustedLaunch". + Known values are: "TrustedLaunch". :paramtype security_type: str or ~azure.mgmt.compute.v2021_04_01.models.DiskSecurityTypes """ super(DiskSecurityProfile, self).__init__(**kwargs) @@ -3664,8 +3662,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype name: str or ~azure.mgmt.compute.v2021_04_01.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -3683,11 +3681,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2021_04_01.models.DiskStorageAccountTypes """ @@ -3706,7 +3704,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, or StandardSSD_ZRS. :vartype sku: ~azure.mgmt.compute.v2021_04_01.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -3737,8 +3735,8 @@ class DiskUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2021_04_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -3760,8 +3758,8 @@ class DiskUpdate(msrest.serialization.Model): ~azure.mgmt.compute.v2021_04_01.models.PropertyUpdatesInProgress :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_04_01.models.PublicNetworkAccess """ @@ -3797,24 +3795,24 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, max_shares: Optional[int] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, - purchase_plan: Optional["PurchasePlanAutoGenerated"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, + purchase_plan: Optional["_models.PurchasePlanAutoGenerated"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, **kwargs ): """ @@ -3823,7 +3821,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, or StandardSSD_ZRS. :paramtype sku: ~azure.mgmt.compute.v2021_04_01.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -3854,8 +3852,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2021_04_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -3875,8 +3873,8 @@ def __init__( :paramtype supported_capabilities: ~azure.mgmt.compute.v2021_04_01.models.SupportedCapabilities :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_04_01.models.PublicNetworkAccess """ @@ -3909,7 +3907,7 @@ class Encryption(msrest.serialization.Model): :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Possible values include: + :ivar type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype type: str or ~azure.mgmt.compute.v2021_04_01.models.EncryptionType @@ -3924,14 +3922,14 @@ def __init__( self, *, disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "EncryptionType"]] = None, + type: Optional[Union[str, "_models.EncryptionType"]] = None, **kwargs ): """ :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Possible values include: + :keyword type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype type: str or ~azure.mgmt.compute.v2021_04_01.models.EncryptionType @@ -3949,7 +3947,7 @@ class EncryptionSetIdentity(msrest.serialization.Model): :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted - resources to lose access to the keys. Possible values include: "SystemAssigned", "None". + resources to lose access to the keys. Known values are: "SystemAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSetIdentityType :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a @@ -3975,15 +3973,14 @@ class EncryptionSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "DiskEncryptionSetIdentityType"]] = None, + type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, **kwargs ): """ :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the - encrypted resources to lose access to the keys. Possible values include: "SystemAssigned", - "None". + encrypted resources to lose access to the keys. Known values are: "SystemAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSetIdentityType """ super(EncryptionSetIdentity, self).__init__(**kwargs) @@ -4025,7 +4022,7 @@ def __init__( self, *, enabled: bool, - encryption_settings: Optional[List["EncryptionSettingsElement"]] = None, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, encryption_settings_version: Optional[str] = None, **kwargs ): @@ -4067,8 +4064,8 @@ class EncryptionSettingsElement(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -4089,7 +4086,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.compute.v2021_04_01.models.ExtendedLocationTypes """ @@ -4102,13 +4099,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.compute.v2021_04_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -4121,7 +4118,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read", "Write". + :ivar access: Required. Known values are: "None", "Read", "Write". :vartype access: str or ~azure.mgmt.compute.v2021_04_01.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -4140,12 +4137,12 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read", "Write". + :keyword access: Required. Known values are: "None", "Read", "Write". :paramtype access: str or ~azure.mgmt.compute.v2021_04_01.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -4169,7 +4166,7 @@ class HardwareProfile(msrest.serialization.Model): `_. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The - available VM sizes depend on region and availability set. Possible values include: "Basic_A0", + available VM sizes depend on region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", @@ -4214,7 +4211,7 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, **kwargs ): """ @@ -4229,7 +4226,7 @@ def __init__( `_. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The - available VM sizes depend on region and availability set. Possible values include: "Basic_A0", + available VM sizes depend on region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", @@ -4298,8 +4295,8 @@ class Image(Resource): :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Possible - values include: "V1", "V2". + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGenerationTypes """ @@ -4330,10 +4327,10 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -4351,7 +4348,7 @@ def __init__( from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the user to specify the property if we cannot deduce it from the source managed - resource. Possible values include: "V1", "V2". + resource. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGenerationTypes """ @@ -4375,16 +4372,15 @@ class ImageDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_04_01.models.StorageAccountTypes @@ -4407,13 +4403,13 @@ class ImageDisk(msrest.serialization.Model): def __init__( self, *, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -4426,16 +4422,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_04_01.models.StorageAccountTypes @@ -4468,16 +4463,15 @@ class ImageDataDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_04_01.models.StorageAccountTypes @@ -4510,13 +4504,13 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -4529,16 +4523,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_04_01.models.StorageAccountTypes @@ -4621,7 +4614,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -4651,16 +4644,15 @@ class ImageOSDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_04_01.models.StorageAccountTypes @@ -4670,10 +4662,10 @@ class ImageOSDisk(ImageDisk): ~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSetParameters :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemStateTypes """ @@ -4697,15 +4689,15 @@ class ImageOSDisk(ImageDisk): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -4718,16 +4710,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_04_01.models.StorageAccountTypes @@ -4737,11 +4728,10 @@ def __init__( ~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSetParameters :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemStateTypes """ super(ImageOSDisk, self).__init__(snapshot=snapshot, managed_disk=managed_disk, blob_uri=blob_uri, caching=caching, disk_size_gb=disk_size_gb, storage_account_type=storage_account_type, disk_encryption_set=disk_encryption_set, **kwargs) @@ -4850,8 +4840,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -4892,8 +4882,8 @@ class ImageUpdate(UpdateResource): :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Possible - values include: "V1", "V2". + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGenerationTypes """ @@ -4914,9 +4904,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -4930,7 +4920,7 @@ def __init__( from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the user to specify the property if we cannot deduce it from the source managed - resource. Possible values include: "V1", "V2". + resource. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGenerationTypes """ @@ -4978,7 +4968,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2021_04_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -5000,7 +4990,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -5009,7 +4999,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2021_04_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -5053,7 +5043,7 @@ def __init__( self, *, key_url: str, - source_vault: Optional["SourceVault"] = None, + source_vault: Optional["_models.SourceVault"] = None, **kwargs ): """ @@ -5094,7 +5084,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -5133,7 +5123,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -5173,7 +5163,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -5212,7 +5202,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -5233,8 +5223,8 @@ class LastPatchInstallationSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_04_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -5341,9 +5331,9 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, provision_vm_agent: Optional[bool] = None, - patch_settings: Optional["LinuxPatchSettings"] = None, + patch_settings: Optional["_models.LinuxPatchSettings"] = None, **kwargs ): """ @@ -5396,7 +5386,7 @@ class LinuxParameters(msrest.serialization.Model): def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "VMGuestPatchClassificationLinux"]]] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationLinux"]]] = None, package_name_masks_to_include: Optional[List[str]] = None, package_name_masks_to_exclude: Optional[List[str]] = None, maintenance_run_id: Optional[str] = None, @@ -5432,15 +5422,15 @@ class LinuxPatchSettings(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. Possible values include: "ImageDefault", + The property provisionVMAgent must be true. Known values are: "ImageDefault", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2021_04_01.models.LinuxVMGuestPatchMode :ivar assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :vartype assessment_mode: str or ~azure.mgmt.compute.v2021_04_01.models.LinuxPatchAssessmentMode """ @@ -5453,8 +5443,8 @@ class LinuxPatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "LinuxVMGuestPatchMode"]] = None, - assessment_mode: Optional[Union[str, "LinuxPatchAssessmentMode"]] = None, + patch_mode: Optional[Union[str, "_models.LinuxVMGuestPatchMode"]] = None, + assessment_mode: Optional[Union[str, "_models.LinuxPatchAssessmentMode"]] = None, **kwargs ): """ @@ -5463,15 +5453,15 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. Possible values include: "ImageDefault", + The property provisionVMAgent must be true. Known values are: "ImageDefault", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2021_04_01.models.LinuxVMGuestPatchMode :keyword assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :paramtype assessment_mode: str or ~azure.mgmt.compute.v2021_04_01.models.LinuxPatchAssessmentMode """ @@ -5504,7 +5494,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -5672,8 +5662,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2021_04_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -5698,7 +5688,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -5714,8 +5704,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2021_04_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -5737,8 +5727,8 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_04_01.models.StorageAccountTypes @@ -5758,16 +5748,16 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_04_01.models.StorageAccountTypes @@ -5790,7 +5780,7 @@ class NetworkInterfaceReference(SubResource): than 1 network interface. :vartype primary: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions """ @@ -5805,7 +5795,7 @@ def __init__( *, id: Optional[str] = None, primary: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -5815,7 +5805,7 @@ def __init__( than 1 network interface. :paramtype primary: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions """ super(NetworkInterfaceReference, self).__init__(id=id, **kwargs) @@ -5831,8 +5821,7 @@ class NetworkProfile(msrest.serialization.Model): :vartype network_interfaces: list[~azure.mgmt.compute.v2021_04_01.models.NetworkInterfaceReference] :ivar network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. Possible values include: - "2020-11-01". + networking resources in the Network Interface Configurations. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkApiVersion :ivar network_interface_configurations: Specifies the networking configurations that will be used to create the virtual machine networking resources. @@ -5849,9 +5838,9 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, - network_interface_configurations: Optional[List["VirtualMachineNetworkInterfaceConfiguration"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceConfiguration"]] = None, **kwargs ): """ @@ -5860,8 +5849,7 @@ def __init__( :paramtype network_interfaces: list[~azure.mgmt.compute.v2021_04_01.models.NetworkInterfaceReference] :keyword network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. Possible values include: - "2020-11-01". + networking resources in the Network Interface Configurations. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkApiVersion :keyword network_interface_configurations: Specifies the networking configurations that will be used to create the virtual machine networking resources. @@ -5879,11 +5867,9 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :ivar service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2021_04_01.models.OrchestrationServiceNames - :ivar action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :ivar action: Required. The action to be performed. Known values are: "Resume", "Suspend". :vartype action: str or ~azure.mgmt.compute.v2021_04_01.models.OrchestrationServiceStateAction """ @@ -5900,17 +5886,15 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): def __init__( self, *, - service_name: Union[str, "OrchestrationServiceNames"], - action: Union[str, "OrchestrationServiceStateAction"], + service_name: Union[str, "_models.OrchestrationServiceNames"], + action: Union[str, "_models.OrchestrationServiceStateAction"], **kwargs ): """ - :keyword service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :keyword service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :paramtype service_name: str or ~azure.mgmt.compute.v2021_04_01.models.OrchestrationServiceNames - :keyword action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :keyword action: Required. The action to be performed. Known values are: "Resume", "Suspend". :paramtype action: str or ~azure.mgmt.compute.v2021_04_01.models.OrchestrationServiceStateAction """ @@ -5924,9 +5908,9 @@ class OrchestrationServiceSummary(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar service_name: The name of the service. Possible values include: "AutomaticRepairs". + :ivar service_name: The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2021_04_01.models.OrchestrationServiceNames - :ivar service_state: The current state of the service. Possible values include: "NotRunning", + :ivar service_state: The current state of the service. Known values are: "NotRunning", "Running", "Suspended". :vartype service_state: str or ~azure.mgmt.compute.v2021_04_01.models.OrchestrationServiceState """ @@ -5959,8 +5943,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -5976,8 +5960,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -5991,7 +5974,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -6004,8 +5987,8 @@ class OSDisk(msrest.serialization.Model): used, the OS disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the os disk is retained after VM is deleted. :code:`
`:code:`
` The default value is set to **detach**. For an ephemeral OS Disk, the default value is set to - **Delete**. User cannot change the delete option for ephemeral OS Disk. Possible values - include: "Delete", "Detach". + **Delete**. User cannot change the delete option for ephemeral OS Disk. Known values are: + "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskDeleteOptionTypes """ @@ -6031,25 +6014,25 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -6065,8 +6048,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -6080,7 +6062,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -6093,8 +6075,8 @@ def __init__( value is used, the OS disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the os disk is retained after VM is deleted. :code:`
`:code:`
` The default value is set to **detach**. For an ephemeral OS Disk, the default value is set to - **Delete**. User cannot change the delete option for ephemeral OS Disk. Possible values - include: "Delete", "Detach". + **Delete**. User cannot change the delete option for ephemeral OS Disk. Known values are: + "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskDeleteOptionTypes """ super(OSDisk, self).__init__(**kwargs) @@ -6117,8 +6099,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes """ @@ -6133,12 +6115,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -6235,9 +6217,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, require_guest_provision_signal: Optional[bool] = None, **kwargs @@ -6340,8 +6322,7 @@ class PatchInstallationDetail(msrest.serialization.Model): :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] :ivar installation_state: The state of the patch after the installation operation completed. - Possible values include: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", - "Pending". + Known values are: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", "Pending". :vartype installation_state: str or ~azure.mgmt.compute.v2021_04_01.models.PatchInstallationState """ @@ -6391,8 +6372,8 @@ class PatchSettings(msrest.serialization.Model): **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2021_04_01.models.WindowsVMGuestPatchMode :ivar enable_hotpatching: Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must @@ -6402,8 +6383,8 @@ class PatchSettings(msrest.serialization.Model): machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :vartype assessment_mode: str or ~azure.mgmt.compute.v2021_04_01.models.WindowsPatchAssessmentMode """ @@ -6417,9 +6398,9 @@ class PatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "WindowsVMGuestPatchMode"]] = None, + patch_mode: Optional[Union[str, "_models.WindowsVMGuestPatchMode"]] = None, enable_hotpatching: Optional[bool] = None, - assessment_mode: Optional[Union[str, "WindowsPatchAssessmentMode"]] = None, + assessment_mode: Optional[Union[str, "_models.WindowsPatchAssessmentMode"]] = None, **kwargs ): """ @@ -6432,8 +6413,8 @@ def __init__( **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2021_04_01.models.WindowsVMGuestPatchMode :keyword enable_hotpatching: Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must @@ -6443,8 +6424,8 @@ def __init__( machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :paramtype assessment_mode: str or ~azure.mgmt.compute.v2021_04_01.models.WindowsPatchAssessmentMode """ @@ -6547,7 +6528,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype private_link_service_connection_state: ~azure.mgmt.compute.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.compute.v2021_04_01.models.PrivateEndpointConnectionProvisioningState """ @@ -6572,7 +6553,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): def __init__( self, *, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -6608,7 +6589,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -6693,7 +6674,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -6708,7 +6689,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.compute.v2021_04_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -6727,14 +6708,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, actions_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.compute.v2021_04_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -6796,7 +6777,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2021_04_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -6843,8 +6824,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -6855,7 +6836,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2021_04_01.models.ProximityPlacementGroupType :keyword colocation_status: Describes colocation status of the Proximity Placement Group. @@ -6892,7 +6873,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -6971,9 +6952,9 @@ def __init__( class PublicIPAddressSku(msrest.serialization.Model): """Describes the public IP Sku. - :ivar name: Specify public IP sku name. Possible values include: "Basic", "Standard". + :ivar name: Specify public IP sku name. Known values are: "Basic", "Standard". :vartype name: str or ~azure.mgmt.compute.v2021_04_01.models.PublicIPAddressSkuName - :ivar tier: Specify public IP sku tier. Possible values include: "Regional", "Global". + :ivar tier: Specify public IP sku tier. Known values are: "Regional", "Global". :vartype tier: str or ~azure.mgmt.compute.v2021_04_01.models.PublicIPAddressSkuTier """ @@ -6985,14 +6966,14 @@ class PublicIPAddressSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "PublicIPAddressSkuName"]] = None, - tier: Optional[Union[str, "PublicIPAddressSkuTier"]] = None, + name: Optional[Union[str, "_models.PublicIPAddressSkuName"]] = None, + tier: Optional[Union[str, "_models.PublicIPAddressSkuTier"]] = None, **kwargs ): """ - :keyword name: Specify public IP sku name. Possible values include: "Basic", "Standard". + :keyword name: Specify public IP sku name. Known values are: "Basic", "Standard". :paramtype name: str or ~azure.mgmt.compute.v2021_04_01.models.PublicIPAddressSkuName - :keyword tier: Specify public IP sku tier. Possible values include: "Regional", "Global". + :keyword tier: Specify public IP sku tier. Known values are: "Regional", "Global". :paramtype tier: str or ~azure.mgmt.compute.v2021_04_01.models.PublicIPAddressSkuTier """ super(PublicIPAddressSku, self).__init__(**kwargs) @@ -7161,7 +7142,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_user_agent: Group query result by User Agent. :vartype group_by_user_agent: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2021_04_01.models.IntervalInMins """ @@ -7190,7 +7171,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -7217,7 +7198,7 @@ def __init__( :keyword group_by_user_agent: Group query result by User Agent. :paramtype group_by_user_agent: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2021_04_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, group_by_client_application_id=group_by_client_application_id, group_by_user_agent=group_by_user_agent, **kwargs) @@ -7286,7 +7267,7 @@ class RestorePoint(ProxyResource): :ivar provisioning_state: Gets the provisioning state of the restore point. :vartype provisioning_state: str :ivar consistency_mode: Gets the consistency mode for the restore point. Please refer to - https://aka.ms/RestorePoints for more details. Possible values include: "CrashConsistent", + https://aka.ms/RestorePoints for more details. Known values are: "CrashConsistent", "FileSystemConsistent", "ApplicationConsistent". :vartype consistency_mode: str or ~azure.mgmt.compute.v2021_04_01.models.ConsistencyModeTypes :ivar time_created: Gets the creation time of the restore point. @@ -7316,7 +7297,7 @@ class RestorePoint(ProxyResource): def __init__( self, *, - exclude_disks: Optional[List["ApiEntityReference"]] = None, + exclude_disks: Optional[List["_models.ApiEntityReference"]] = None, time_created: Optional[datetime.datetime] = None, **kwargs ): @@ -7391,7 +7372,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source: Optional["RestorePointCollectionSourceProperties"] = None, + source: Optional["_models.RestorePointCollectionSourceProperties"] = None, **kwargs ): """ @@ -7429,7 +7410,7 @@ class RestorePointCollectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RestorePointCollection"]] = None, + value: Optional[List["_models.RestorePointCollection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -7517,7 +7498,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["RestorePointCollectionSourceProperties"] = None, + source: Optional["_models.RestorePointCollectionSourceProperties"] = None, **kwargs ): """ @@ -7571,13 +7552,13 @@ class RestorePointSourceMetadata(msrest.serialization.Model): def __init__( self, *, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["RestorePointSourceVMStorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.RestorePointSourceVMStorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, license_type: Optional[str] = None, vm_id: Optional[str] = None, - security_profile: Optional["SecurityProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, location: Optional[str] = None, **kwargs ): @@ -7618,7 +7599,7 @@ class RestorePointSourceVMDataDisk(msrest.serialization.Model): :vartype lun: int :ivar name: Gets the disk name. :vartype name: str - :ivar caching: Gets the caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :ivar disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired size for existing OS and Data disks. @@ -7643,10 +7624,10 @@ def __init__( *, lun: Optional[int] = None, name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - disk_restore_point: Optional["ApiEntityReference"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + disk_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs ): """ @@ -7654,8 +7635,7 @@ def __init__( :paramtype lun: int :keyword name: Gets the disk name. :paramtype name: str - :keyword caching: Gets the caching type. Possible values include: "None", "ReadOnly", - "ReadWrite". + :keyword caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :keyword disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired size for existing OS and Data disks. @@ -7677,13 +7657,13 @@ def __init__( class RestorePointSourceVMOSDisk(msrest.serialization.Model): """Describes an Operating System disk. - :ivar os_type: Gets the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: Gets the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemType :ivar encryption_settings: Gets the disk encryption settings. :vartype encryption_settings: ~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSettings :ivar name: Gets the disk name. :vartype name: str - :ivar caching: Gets the caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :ivar disk_size_gb: Gets the disk size in GB. :vartype disk_size_gb: int @@ -7706,24 +7686,23 @@ class RestorePointSourceVMOSDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Optional[Union[str, "OperatingSystemType"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemType"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - disk_restore_point: Optional["ApiEntityReference"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + disk_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs ): """ - :keyword os_type: Gets the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: Gets the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemType :keyword encryption_settings: Gets the disk encryption settings. :paramtype encryption_settings: ~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSettings :keyword name: Gets the disk name. :paramtype name: str - :keyword caching: Gets the caching type. Possible values include: "None", "ReadOnly", - "ReadWrite". + :keyword caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :keyword disk_size_gb: Gets the disk size in GB. :paramtype disk_size_gb: int @@ -7760,8 +7739,8 @@ class RestorePointSourceVMStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["RestorePointSourceVMOSDisk"] = None, - data_disks: Optional[List["RestorePointSourceVMDataDisk"]] = None, + os_disk: Optional["_models.RestorePointSourceVMOSDisk"] = None, + data_disks: Optional[List["_models.RestorePointSourceVMDataDisk"]] = None, **kwargs ): """ @@ -7992,13 +7971,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2021_04_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2021_04_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -8111,8 +8090,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -8141,7 +8119,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -8151,8 +8129,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -8176,8 +8153,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -8213,11 +8189,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -8225,8 +8201,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -8272,7 +8247,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -8353,7 +8328,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -8436,7 +8411,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -8475,7 +8450,7 @@ class ScaleInPolicy(msrest.serialization.Model): def __init__( self, *, - rules: Optional[List[Union[str, "VirtualMachineScaleSetScaleInRules"]]] = None, + rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, **kwargs ): """ @@ -8516,7 +8491,7 @@ class ScheduledEventsProfile(msrest.serialization.Model): def __init__( self, *, - terminate_notification_profile: Optional["TerminateNotificationProfile"] = None, + terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs ): """ @@ -8543,8 +8518,7 @@ class SecurityProfile(msrest.serialization.Model): :vartype encryption_at_host: bool :ivar security_type: Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not - be enabled unless this property is set as TrustedLaunch. Possible values include: - "TrustedLaunch". + be enabled unless this property is set as TrustedLaunch. Known values are: "TrustedLaunch". :vartype security_type: str or ~azure.mgmt.compute.v2021_04_01.models.SecurityTypes """ @@ -8557,9 +8531,9 @@ class SecurityProfile(msrest.serialization.Model): def __init__( self, *, - uefi_settings: Optional["UefiSettings"] = None, + uefi_settings: Optional["_models.UefiSettings"] = None, encryption_at_host: Optional[bool] = None, - security_type: Optional[Union[str, "SecurityTypes"]] = None, + security_type: Optional[Union[str, "_models.SecurityTypes"]] = None, **kwargs ): """ @@ -8574,8 +8548,7 @@ def __init__( :paramtype encryption_at_host: bool :keyword security_type: Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not - be enabled unless this property is set as TrustedLaunch. Possible values include: - "TrustedLaunch". + be enabled unless this property is set as TrustedLaunch. Known values are: "TrustedLaunch". :paramtype security_type: str or ~azure.mgmt.compute.v2021_04_01.models.SecurityTypes """ super(SecurityProfile, self).__init__(**kwargs) @@ -8682,10 +8655,10 @@ class Snapshot(Resource): :vartype extended_location: ~azure.mgmt.compute.v2021_04_01.models.ExtendedLocation :ivar time_created: The time when the snapshot was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. @@ -8703,7 +8676,7 @@ class Snapshot(Resource): :vartype disk_size_gb: int :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. :vartype disk_size_bytes: long - :ivar disk_state: The state of the snapshot. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the snapshot. Known values are: "Unattached", "Attached", "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2021_04_01.models.DiskState :ivar unique_id: Unique Guid identifying the resource. @@ -8720,16 +8693,16 @@ class Snapshot(Resource): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2021_04_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. :vartype disk_access_id: str :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_04_01.models.PublicNetworkAccess :ivar completion_percent: Percentage complete for the background copy when a resource is @@ -8785,21 +8758,21 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - extended_location: Optional["ExtendedLocation"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlanAutoGenerated"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlanAutoGenerated"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, incremental: Optional[bool] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, completion_percent: Optional[float] = None, **kwargs ): @@ -8815,10 +8788,10 @@ def __init__( :keyword extended_location: The extended location where the snapshot will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2021_04_01.models.ExtendedLocation - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. @@ -8844,8 +8817,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2021_04_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -8853,8 +8826,8 @@ def __init__( :paramtype disk_access_id: str :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_04_01.models.PublicNetworkAccess :keyword completion_percent: Percentage complete for the background copy when a resource is @@ -8910,7 +8883,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -8931,8 +8904,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2021_04_01.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -8950,12 +8922,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2021_04_01.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -8972,7 +8943,7 @@ class SnapshotUpdate(msrest.serialization.Model): an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. :vartype sku: ~azure.mgmt.compute.v2021_04_01.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -8986,16 +8957,16 @@ class SnapshotUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2021_04_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. :vartype disk_access_id: str :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_04_01.models.PublicNetworkAccess """ @@ -9017,15 +8988,15 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, **kwargs ): """ @@ -9035,7 +9006,7 @@ def __init__( is an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. :paramtype sku: ~azure.mgmt.compute.v2021_04_01.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -9049,8 +9020,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2021_04_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -9058,8 +9029,8 @@ def __init__( :paramtype disk_access_id: str :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_04_01.models.PublicNetworkAccess """ @@ -9152,7 +9123,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -9347,7 +9318,7 @@ class SshPublicKeysGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["SshPublicKeyResource"], + value: List["_models.SshPublicKeyResource"], next_link: Optional[str] = None, **kwargs ): @@ -9429,9 +9400,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -9503,7 +9474,7 @@ def __init__( self, *, id: Optional[str] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -9743,7 +9714,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2021_04_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2021_04_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2021_04_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -9790,7 +9761,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2021_04_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -9830,8 +9801,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2021_04_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -9851,9 +9822,9 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["AutomaticOSUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, + automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, **kwargs ): """ @@ -9861,8 +9832,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2021_04_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -9916,7 +9887,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -10078,8 +10049,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -10196,14 +10167,13 @@ class VirtualMachine(Resource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_04_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -10313,31 +10283,31 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, platform_fault_domain: Optional[int] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, - capacity_reservation: Optional["CapacityReservationProfile"] = None, + capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, **kwargs ): """ @@ -10403,15 +10373,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_04_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -10514,8 +10483,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -10540,8 +10509,8 @@ class VirtualMachineAssessPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_04_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -10788,7 +10757,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -10857,7 +10826,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -10994,8 +10963,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -11032,7 +11001,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -11173,8 +11142,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2021_04_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -11198,15 +11167,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2021_04_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -11260,7 +11229,7 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, **kwargs ): """ @@ -11311,8 +11280,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2021_04_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: "V1", - "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGenerationTypes :ivar disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -11349,14 +11317,14 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, - disallowed: Optional["DisallowedConfiguration"] = None, - features: Optional[List["VirtualMachineImageFeature"]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, + automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, + disallowed: Optional["_models.DisallowedConfiguration"] = None, + features: Optional[List["_models.VirtualMachineImageFeature"]] = None, **kwargs ): """ @@ -11383,8 +11351,7 @@ def __init__( image. :paramtype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2021_04_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: - "V1", "V2". + :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGenerationTypes :keyword disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -11444,7 +11411,7 @@ class VirtualMachineInstallPatchesParameters(msrest.serialization.Model): run. It must be an ISO 8601-compliant duration string such as PT4H (4 hours). :vartype maximum_duration: str :ivar reboot_setting: Required. Defines when it is acceptable to reboot a VM during a software - update operation. Possible values include: "IfRequired", "Never", "Always". + update operation. Known values are: "IfRequired", "Never", "Always". :vartype reboot_setting: str or ~azure.mgmt.compute.v2021_04_01.models.VMGuestPatchRebootSetting :ivar windows_parameters: Input for InstallPatches on a Windows VM, as directly received by the @@ -11471,9 +11438,9 @@ def __init__( self, *, maximum_duration: str, - reboot_setting: Union[str, "VMGuestPatchRebootSetting"], - windows_parameters: Optional["WindowsParameters"] = None, - linux_parameters: Optional["LinuxParameters"] = None, + reboot_setting: Union[str, "_models.VMGuestPatchRebootSetting"], + windows_parameters: Optional["_models.WindowsParameters"] = None, + linux_parameters: Optional["_models.LinuxParameters"] = None, **kwargs ): """ @@ -11481,7 +11448,7 @@ def __init__( will run. It must be an ISO 8601-compliant duration string such as PT4H (4 hours). :paramtype maximum_duration: str :keyword reboot_setting: Required. Defines when it is acceptable to reboot a VM during a - software update operation. Possible values include: "IfRequired", "Never", "Always". + software update operation. Known values are: "IfRequired", "Never", "Always". :paramtype reboot_setting: str or ~azure.mgmt.compute.v2021_04_01.models.VMGuestPatchRebootSetting :keyword windows_parameters: Input for InstallPatches on a Windows VM, as directly received by @@ -11505,14 +11472,14 @@ class VirtualMachineInstallPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Failed", "Succeeded", "Unknown" or - "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_04_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. :vartype installation_activity_id: str - :ivar reboot_status: The reboot state of the VM following completion of the operation. Possible - values include: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". + :ivar reboot_status: The reboot state of the VM following completion of the operation. Known + values are: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". :vartype reboot_status: str or ~azure.mgmt.compute.v2021_04_01.models.VMGuestPatchRebootStatus :ivar maintenance_window_exceeded: Whether the operation ran out of time before it completed all its intended actions. @@ -11607,8 +11574,8 @@ class VirtualMachineInstanceView(msrest.serialization.Model): :vartype os_name: str :ivar os_version: The version of Operating System running on the virtual machine. :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGenerationType :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. :vartype rdp_thumb_print: str @@ -11672,15 +11639,15 @@ def __init__( computer_name: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationType"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, - patch_status: Optional["VirtualMachinePatchStatus"] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, + patch_status: Optional["_models.VirtualMachinePatchStatus"] = None, **kwargs ): """ @@ -11695,7 +11662,7 @@ def __init__( :keyword os_version: The version of Operating System running on the virtual machine. :paramtype os_version: str :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_04_01.models.HyperVGenerationType :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. @@ -11795,7 +11762,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -11822,7 +11789,7 @@ class VirtualMachineNetworkInterfaceConfiguration(msrest.serialization.Model): than 1 network interface. :vartype primary: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated networking-enabled. @@ -11865,14 +11832,14 @@ def __init__( *, name: str, primary: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, enable_ip_forwarding: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineNetworkInterfaceDnsSettingsConfiguration"] = None, - ip_configurations: Optional[List["VirtualMachineNetworkInterfaceIPConfiguration"]] = None, - dscp_configuration: Optional["SubResource"] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineNetworkInterfaceDnsSettingsConfiguration"] = None, + ip_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceIPConfiguration"]] = None, + dscp_configuration: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -11882,7 +11849,7 @@ def __init__( than 1 network interface. :paramtype primary: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated networking-enabled. @@ -11957,7 +11924,7 @@ class VirtualMachineNetworkInterfaceIPConfiguration(msrest.serialization.Model): ~azure.mgmt.compute.v2021_04_01.models.VirtualMachinePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_04_01.models.IPVersions :ivar application_security_groups: Specifies an array of references to application security group. @@ -11995,13 +11962,13 @@ def __init__( self, *, name: str, - subnet: Optional["SubResource"] = None, + subnet: Optional["_models.SubResource"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachinePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersions"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachinePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersions"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -12017,7 +11984,7 @@ def __init__( ~azure.mgmt.compute.v2021_04_01.models.VirtualMachinePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_04_01.models.IPVersions :keyword application_security_groups: Specifies an array of references to application security group. @@ -12077,8 +12044,8 @@ class VirtualMachinePatchStatus(msrest.serialization.Model): def __init__( self, *, - available_patch_summary: Optional["AvailablePatchSummary"] = None, - last_patch_installation_summary: Optional["LastPatchInstallationSummary"] = None, + available_patch_summary: Optional["_models.AvailablePatchSummary"] = None, + last_patch_installation_summary: Optional["_models.LastPatchInstallationSummary"] = None, **kwargs ): """ @@ -12109,7 +12076,7 @@ class VirtualMachinePublicIPAddressConfiguration(msrest.serialization.Model): :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. :vartype idle_timeout_in_minutes: int :ivar delete_option: Specify what happens to the public IP address when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions :ivar dns_settings: The dns settings to be applied on the publicIP addresses . :vartype dns_settings: @@ -12120,10 +12087,10 @@ class VirtualMachinePublicIPAddressConfiguration(msrest.serialization.Model): :vartype public_ip_prefix: ~azure.mgmt.compute.v2021_04_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2021_04_01.models.IPVersions - :ivar public_ip_allocation_method: Specify the public IP allocation type. Possible values - include: "Dynamic", "Static". + :ivar public_ip_allocation_method: Specify the public IP allocation type. Known values are: + "Dynamic", "Static". :vartype public_ip_allocation_method: str or ~azure.mgmt.compute.v2021_04_01.models.PublicIPAllocationMethod """ @@ -12148,14 +12115,14 @@ def __init__( self, *, name: str, - sku: Optional["PublicIPAddressSku"] = None, + sku: Optional["_models.PublicIPAddressSku"] = None, idle_timeout_in_minutes: Optional[int] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, - dns_settings: Optional["VirtualMachinePublicIPAddressDnsSettingsConfiguration"] = None, - ip_tags: Optional[List["VirtualMachineIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersions"]] = None, - public_ip_allocation_method: Optional[Union[str, "PublicIPAllocationMethod"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachinePublicIPAddressDnsSettingsConfiguration"] = None, + ip_tags: Optional[List["_models.VirtualMachineIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersions"]] = None, + public_ip_allocation_method: Optional[Union[str, "_models.PublicIPAllocationMethod"]] = None, **kwargs ): """ @@ -12166,7 +12133,7 @@ def __init__( :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. :paramtype idle_timeout_in_minutes: int :keyword delete_option: Specify what happens to the public IP address when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions :keyword dns_settings: The dns settings to be applied on the publicIP addresses . :paramtype dns_settings: @@ -12177,10 +12144,10 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2021_04_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2021_04_01.models.IPVersions - :keyword public_ip_allocation_method: Specify the public IP allocation type. Possible values - include: "Dynamic", "Static". + :keyword public_ip_allocation_method: Specify the public IP allocation type. Known values are: + "Dynamic", "Static". :paramtype public_ip_allocation_method: str or ~azure.mgmt.compute.v2021_04_01.models.PublicIPAllocationMethod """ @@ -12338,9 +12305,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -12395,7 +12362,7 @@ def __init__( class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): """The instance view of a virtual machine run command. - :ivar execution_state: Script execution status. Possible values include: "Unknown", "Pending", + :ivar execution_state: Script execution status. Known values are: "Unknown", "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :vartype execution_state: str or ~azure.mgmt.compute.v2021_04_01.models.ExecutionState :ivar execution_message: Communicate script configuration errors or execution messages. @@ -12428,19 +12395,19 @@ class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): def __init__( self, *, - execution_state: Optional[Union[str, "ExecutionState"]] = None, + execution_state: Optional[Union[str, "_models.ExecutionState"]] = None, execution_message: Optional[str] = None, exit_code: Optional[int] = None, output: Optional[str] = None, error: Optional[str] = None, start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ - :keyword execution_state: Script execution status. Possible values include: "Unknown", - "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". + :keyword execution_state: Script execution status. Known values are: "Unknown", "Pending", + "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :paramtype execution_state: str or ~azure.mgmt.compute.v2021_04_01.models.ExecutionState :keyword execution_message: Communicate script configuration errors or execution messages. :paramtype execution_message: str @@ -12530,7 +12497,7 @@ class VirtualMachineRunCommandsListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineRunCommand"], + value: List["_models.VirtualMachineRunCommand"], next_link: Optional[str] = None, **kwargs ): @@ -12606,9 +12573,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -12735,7 +12702,7 @@ class VirtualMachineScaleSet(Resource): chosen for removal when a Virtual Machine Scale Set is scaled-in. :vartype scale_in_policy: ~azure.mgmt.compute.v2021_04_01.models.ScaleInPolicy :ivar orchestration_mode: Specifies the orchestration mode for the virtual machine scale set. - Possible values include: "Uniform", "Flexible". + Known values are: "Uniform", "Flexible". :vartype orchestration_mode: str or ~azure.mgmt.compute.v2021_04_01.models.OrchestrationMode :ivar spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale set. @@ -12785,25 +12752,25 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - orchestration_mode: Optional[Union[str, "OrchestrationMode"]] = None, - spot_restore_policy: Optional["SpotRestorePolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + orchestration_mode: Optional[Union[str, "_models.OrchestrationMode"]] = None, + spot_restore_policy: Optional["_models.SpotRestorePolicy"] = None, **kwargs ): """ @@ -12869,7 +12836,7 @@ def __init__( chosen for removal when a Virtual Machine Scale Set is scaled-in. :paramtype scale_in_policy: ~azure.mgmt.compute.v2021_04_01.models.ScaleInPolicy :keyword orchestration_mode: Specifies the orchestration mode for the virtual machine scale - set. Possible values include: "Uniform", "Flexible". + set. Known values are: "Uniform", "Flexible". :paramtype orchestration_mode: str or ~azure.mgmt.compute.v2021_04_01.models.OrchestrationMode :keyword spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale set. @@ -12913,14 +12880,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -12960,12 +12926,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -12980,14 +12946,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -13162,7 +13127,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -13199,7 +13164,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, extensions_time_budget: Optional[str] = None, **kwargs ): @@ -13351,7 +13316,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2021_04_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine @@ -13376,15 +13341,15 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2021_04_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual @@ -13467,7 +13432,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -13528,7 +13493,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_04_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -13572,14 +13537,14 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -13597,7 +13562,7 @@ def __init__( ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_04_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -13689,7 +13654,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -13730,7 +13695,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -13770,7 +13735,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -13810,7 +13775,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -13830,8 +13795,8 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): """Describes the parameters of a ScaleSet managed disk. :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_04_01.models.StorageAccountTypes @@ -13849,14 +13814,14 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_04_01.models.StorageAccountTypes @@ -13898,7 +13863,7 @@ class VirtualMachineScaleSetNetworkConfiguration(SubResource): :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions """ @@ -13927,11 +13892,11 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -13958,7 +13923,7 @@ def __init__( :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions """ super(VirtualMachineScaleSetNetworkConfiguration, self).__init__(id=id, **kwargs) @@ -14010,7 +13975,7 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetNetworkConfiguration] :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkApiVersion """ @@ -14023,9 +13988,9 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, **kwargs ): """ @@ -14038,7 +14003,7 @@ def __init__( list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetNetworkConfiguration] :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkApiVersion """ super(VirtualMachineScaleSetNetworkProfile, self).__init__(**kwargs) @@ -14057,8 +14022,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -14067,8 +14031,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -14079,8 +14043,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2021_04_01.models.VirtualHardDisk @@ -14112,16 +14076,16 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -14130,8 +14094,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -14140,8 +14103,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_04_01.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -14153,7 +14116,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_04_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2021_04_01.models.VirtualHardDisk @@ -14247,9 +14210,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -14333,10 +14296,10 @@ class VirtualMachineScaleSetPublicIPAddressConfiguration(msrest.serialization.Mo :vartype public_ip_prefix: ~azure.mgmt.compute.v2021_04_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2021_04_01.models.IPVersion - :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values + are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions """ @@ -14359,13 +14322,13 @@ def __init__( self, *, name: str, - sku: Optional["PublicIPAddressSku"] = None, + sku: Optional["_models.PublicIPAddressSku"] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -14384,10 +14347,10 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2021_04_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2021_04_01.models.IPVersion - :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known + values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions """ super(VirtualMachineScaleSetPublicIPAddressConfiguration, self).__init__(**kwargs) @@ -14547,8 +14510,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -14610,9 +14572,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -14703,18 +14665,18 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - proximity_placement_group: Optional["SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -14792,7 +14754,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_04_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -14826,14 +14788,14 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -14851,7 +14813,7 @@ def __init__( ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_04_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -14905,7 +14867,7 @@ class VirtualMachineScaleSetUpdateNetworkConfiguration(SubResource): :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions """ @@ -14930,11 +14892,11 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -14960,7 +14922,7 @@ def __init__( :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions """ super(VirtualMachineScaleSetUpdateNetworkConfiguration, self).__init__(id=id, **kwargs) @@ -14987,7 +14949,7 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkApiVersion """ @@ -15000,9 +14962,9 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, **kwargs ): """ @@ -15015,7 +14977,7 @@ def __init__( list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_04_01.models.NetworkApiVersion """ super(VirtualMachineScaleSetUpdateNetworkProfile, self).__init__(**kwargs) @@ -15027,7 +14989,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -15059,16 +15021,16 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_04_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -15120,9 +15082,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -15152,8 +15114,8 @@ class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration(msrest.serializat :ivar dns_settings: The dns settings to be applied on the publicIP addresses . :vartype dns_settings: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values + are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions """ @@ -15169,8 +15131,8 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -15181,8 +15143,8 @@ def __init__( :keyword dns_settings: The dns settings to be applied on the publicIP addresses . :paramtype dns_settings: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known + values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_04_01.models.DeleteOptions """ super(VirtualMachineScaleSetUpdatePublicIPAddressConfiguration, self).__init__(**kwargs) @@ -15213,9 +15175,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -15281,15 +15243,15 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, **kwargs ): @@ -15482,18 +15444,18 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - network_profile_configuration: Optional["VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, - protection_policy: Optional["VirtualMachineScaleSetVMProtectionPolicy"] = None, + protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, user_data: Optional[str] = None, **kwargs ): @@ -15659,7 +15621,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, **kwargs ): """ @@ -15718,7 +15680,7 @@ class VirtualMachineScaleSetVMExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineScaleSetVMExtension"]] = None, + value: Optional[List["_models.VirtualMachineScaleSetVMExtension"]] = None, **kwargs ): """ @@ -15994,12 +15956,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -16070,7 +16032,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -16101,7 +16063,7 @@ class VirtualMachineScaleSetVMNetworkProfileConfiguration(msrest.serialization.M def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -16148,15 +16110,14 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -16194,19 +16155,19 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, - capacity_reservation: Optional["CapacityReservationProfile"] = None, + capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, **kwargs ): """ @@ -16242,15 +16203,14 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -16408,7 +16368,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -16434,7 +16394,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype kb_id: str :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] - :ivar reboot_behavior: Describes the reboot requirements of the patch. Possible values include: + :ivar reboot_behavior: Describes the reboot requirements of the patch. Known values are: "Unknown", "NeverReboots", "AlwaysRequiresReboot", "CanRequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.compute.v2021_04_01.models.VMGuestPatchRebootBehavior @@ -16445,7 +16405,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype published_date: ~datetime.datetime :ivar last_modified_date_time: The UTC timestamp of the last update to this patch record. :vartype last_modified_date_time: ~datetime.datetime - :ivar assessment_state: Describes the availability of a given patch. Possible values include: + :ivar assessment_state: Describes the availability of a given patch. Known values are: "Unknown", "Available". :vartype assessment_state: str or ~azure.mgmt.compute.v2021_04_01.models.PatchAssessmentState """ @@ -16589,14 +16549,13 @@ class VirtualMachineUpdate(UpdateResource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_04_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -16694,30 +16653,30 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, platform_fault_domain: Optional[int] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, - capacity_reservation: Optional["CapacityReservationProfile"] = None, + capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, **kwargs ): """ @@ -16779,15 +16738,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_04_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -16942,9 +16900,9 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - patch_settings: Optional["PatchSettings"] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + patch_settings: Optional["_models.PatchSettings"] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -17013,7 +16971,7 @@ class WindowsParameters(msrest.serialization.Model): def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "VMGuestPatchClassificationWindows"]]] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationWindows"]]] = None, kb_numbers_to_include: Optional[List[str]] = None, kb_numbers_to_exclude: Optional[List[str]] = None, exclude_kbs_requiring_reboot: Optional[bool] = None, @@ -17058,7 +17016,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -17073,7 +17031,7 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :vartype protocol: str or ~azure.mgmt.compute.v2021_04_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as @@ -17098,13 +17056,13 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2021_04_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/__init__.py index 431c2df28db4..c782a583e181 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/__init__.py @@ -38,6 +38,9 @@ from ._disk_accesses_operations import DiskAccessesOperations from ._disk_restore_point_operations import DiskRestorePointOperations +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', 'AvailabilitySetsOperations', @@ -71,3 +74,5 @@ 'DiskAccessesOperations', 'DiskRestorePointOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_availability_sets_operations.py index 84d30f173d44..5836d6ec0a86 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +190,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -199,20 +205,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -235,18 +242,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -257,9 +262,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -271,51 +279,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -329,14 +333,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -348,11 +355,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -378,9 +387,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -394,14 +403,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -413,11 +425,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,13 +470,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -471,11 +488,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -498,7 +517,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -510,13 +529,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -525,11 +547,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -555,7 +579,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -568,13 +592,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -583,9 +610,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +623,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -634,7 +665,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -646,13 +677,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +695,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -672,9 +708,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -713,7 +751,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -728,13 +766,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -756,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_capacity_reservation_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_capacity_reservation_groups_operations.py index 8f3a8bad4b45..ea6b1bd0e457 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_capacity_reservation_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_capacity_reservation_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( capacity_reservation_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservationGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( capacity_reservation_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservationGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,9 +123,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_get_request( expand: Optional[Union[str, "_models.CapacityReservationGroupInstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,20 +179,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_by_resource_group_request( expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -211,20 +218,18 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -235,9 +240,12 @@ def build_list_by_subscription_request( expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/capacityReservationGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -247,53 +255,49 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) -class CapacityReservationGroupsOperations(object): - """CapacityReservationGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CapacityReservationGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroup", + parameters: _models.CapacityReservationGroup, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details. @@ -309,14 +313,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroup') @@ -328,11 +335,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -362,9 +371,9 @@ def update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroupUpdate", + parameters: _models.CapacityReservationGroupUpdate, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. @@ -379,14 +388,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroupUpdate') @@ -398,11 +410,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -444,13 +458,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2021-04-01") # type: str + 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( @@ -459,11 +476,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -487,7 +506,7 @@ def get( capacity_reservation_group_name: str, expand: Optional[Union[str, "_models.CapacityReservationGroupInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation that retrieves information about a capacity reservation group. :param resource_group_name: The name of the resource group. @@ -505,13 +524,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.CapacityReservationGroup] request = build_get_request( @@ -521,11 +543,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -552,7 +576,7 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> Iterable["_models.CapacityReservationGroupListResult"]: + ) -> Iterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -570,13 +594,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -586,9 +613,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, 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: @@ -598,9 +627,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -638,7 +669,7 @@ def list_by_subscription( self, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> Iterable["_models.CapacityReservationGroupListResult"]: + ) -> Iterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -654,13 +685,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -669,9 +703,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -680,9 +716,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_capacity_reservations_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_capacity_reservations_operations.py index f27695b3a775..c70a58255fa6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_capacity_reservations_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_capacity_reservations_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( capacity_reservation_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservation] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( capacity_reservation_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservationUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -168,9 +171,12 @@ def build_get_request( expand: Optional[Union[str, "_models.CapacityReservationInstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -183,20 +189,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -207,9 +211,12 @@ def build_list_by_capacity_reservation_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations") # pylint: disable=line-too-long path_format_arguments = { @@ -221,59 +228,58 @@ def build_list_by_capacity_reservation_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CapacityReservationsOperations(object): - """CapacityReservationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CapacityReservationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`capacity_reservations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> "_models.CapacityReservation": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] + ) -> _models.CapacityReservation: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.CapacityReservation] _json = self._serialize.body(parameters, 'CapacityReservation') @@ -286,11 +292,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -321,9 +329,9 @@ def begin_create_or_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> LROPoller["_models.CapacityReservation"]: + ) -> LROPoller[_models.CapacityReservation]: """The operation to create or update a capacity reservation. Please note some properties can be set only during capacity reservation creation. Please refer to https://aka.ms/CapacityReservation for more details. @@ -350,17 +358,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -368,20 +379,27 @@ def begin_create_or_update( 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('CapacityReservation', 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( @@ -399,17 +417,20 @@ def _update_initial( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> Optional["_models.CapacityReservation"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CapacityReservation"]] + ) -> Optional[_models.CapacityReservation]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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[Optional[_models.CapacityReservation]] _json = self._serialize.body(parameters, 'CapacityReservationUpdate') @@ -422,11 +443,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -455,9 +478,9 @@ def begin_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> LROPoller["_models.CapacityReservation"]: + ) -> LROPoller[_models.CapacityReservation]: """The operation to update a capacity reservation. :param resource_group_name: The name of the resource group. @@ -482,17 +505,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -500,20 +526,27 @@ def begin_update( 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('CapacityReservation', 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( @@ -533,13 +566,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements capacity_reservation_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', "2021-04-01") # type: str + 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_initial( @@ -549,11 +585,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -600,21 +638,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -624,8 +667,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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,7 +695,7 @@ def get( capacity_reservation_name: str, expand: Optional[Union[str, "_models.CapacityReservationInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservation": + ) -> _models.CapacityReservation: """The operation that retrieves information about the capacity reservation. :param resource_group_name: The name of the resource group. @@ -665,13 +714,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.CapacityReservation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.CapacityReservation] request = build_get_request( @@ -682,11 +734,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -713,7 +767,7 @@ def list_by_capacity_reservation_group( resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> Iterable["_models.CapacityReservationListResult"]: + ) -> Iterable[_models.CapacityReservationListResult]: """Lists all of the capacity reservations in the specified capacity reservation group. Use the nextLink property in the response to get the next page of capacity reservations. @@ -728,13 +782,16 @@ def list_by_capacity_reservation_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.CapacityReservationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +801,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_capacity_reservation_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: @@ -756,9 +815,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_dedicated_host_groups_operations.py index b89d72b929bc..d00d98dccda1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_dedicated_host_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +172,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -190,9 +193,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -203,18 +209,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -223,9 +227,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") path_format_arguments = { @@ -235,51 +242,47 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostGroupsOperations(object): - """DedicatedHostGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -295,14 +298,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -314,11 +320,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -348,9 +356,9 @@ def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -364,14 +372,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -383,11 +394,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -426,13 +439,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2021-04-01") # type: str + 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( @@ -441,11 +457,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -469,7 +487,7 @@ def get( host_group_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -485,13 +503,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.DedicatedHostGroup] request = build_get_request( @@ -501,11 +522,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -531,7 +554,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -544,13 +567,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -559,9 +585,11 @@ def prepare_request(next_link=None): 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: @@ -570,9 +598,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -609,7 +639,7 @@ def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -620,13 +650,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -634,9 +667,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -644,9 +679,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_dedicated_hosts_operations.py index 73fda3d31489..75bfdf9526f1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHost] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_by_host_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_by_host_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostsOperations(object): - """DedicatedHostsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -341,17 +348,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -359,20 +369,27 @@ def begin_create_or_update( 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('DedicatedHost', 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( @@ -390,17 +407,20 @@ def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -413,11 +433,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -444,9 +466,9 @@ def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -470,17 +492,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -488,20 +513,27 @@ def begin_update( 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('DedicatedHost', 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( @@ -521,13 +553,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements host_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', "2021-04-01") # type: str + 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_initial( @@ -537,11 +572,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -586,21 +623,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -610,8 +652,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -632,7 +680,7 @@ def get( host_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -650,13 +698,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.DedicatedHost] request = build_get_request( @@ -667,11 +718,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -698,7 +751,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostListResult"]: + ) -> Iterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -713,13 +766,16 @@ def list_by_host_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -729,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -741,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disk_accesses_operations.py index 0cbad2658ec4..8ceb4dbcf595 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccess] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccessUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_get_private_link_resources_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,18 +284,16 @@ def build_get_private_link_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -297,14 +304,17 @@ def build_update_a_private_endpoint_connection_request_initial( disk_access_name: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -317,20 +327,18 @@ def build_update_a_private_endpoint_connection_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -344,9 +352,12 @@ def build_get_a_private_endpoint_connection_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -359,18 +370,16 @@ def build_get_a_private_endpoint_connection_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -382,9 +391,12 @@ def build_delete_a_private_endpoint_connection_request_initial( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -397,18 +409,16 @@ def build_delete_a_private_endpoint_connection_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -419,9 +429,12 @@ def build_list_private_endpoint_connections_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections") # pylint: disable=line-too-long path_format_arguments = { @@ -433,58 +446,57 @@ def build_list_private_endpoint_connections_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskAccessesOperations(object): - """DiskAccessesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -496,11 +508,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,9 +544,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -555,37 +569,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -602,17 +626,20 @@ def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -624,11 +651,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -658,9 +687,9 @@ def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -683,37 +712,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -732,7 +771,7 @@ def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -746,13 +785,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.DiskAccess] request = build_get_request( @@ -761,11 +803,13 @@ def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -792,13 +836,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -807,11 +854,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -855,20 +904,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -878,8 +932,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -897,7 +957,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -907,13 +967,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -922,9 +985,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -933,9 +998,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -972,7 +1039,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -980,13 +1047,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -994,9 +1064,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1004,9 +1076,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1045,7 +1119,7 @@ def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -1059,13 +1133,16 @@ def get_private_link_resources( :rtype: ~azure.mgmt.compute.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', "2021-04-01") # 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.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -1074,11 +1151,13 @@ def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1104,17 +1183,20 @@ def _update_a_private_endpoint_connection_initial( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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(private_endpoint_connection, 'PrivateEndpointConnection') @@ -1127,11 +1209,13 @@ def _update_a_private_endpoint_connection_initial( content_type=content_type, json=_json, template_url=self._update_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1162,9 +1246,9 @@ def begin_update_a_private_endpoint_connection( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection under disk access resource, this can't be used to create a new private endpoint connection. @@ -1194,17 +1278,20 @@ def begin_update_a_private_endpoint_connection( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_a_private_endpoint_connection_initial( + raw_result = self._update_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -1212,20 +1299,27 @@ def begin_update_a_private_endpoint_connection( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -1245,7 +1339,7 @@ def get_a_private_endpoint_connection( disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about a private endpoint connection under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1261,13 +1355,16 @@ def get_a_private_endpoint_connection( :rtype: ~azure.mgmt.compute.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', "2021-04-01") # 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.PrivateEndpointConnection] request = build_get_a_private_endpoint_connection_request( @@ -1277,11 +1374,13 @@ def get_a_private_endpoint_connection( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get_a_private_endpoint_connection.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1309,13 +1408,16 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsiste private_endpoint_connection_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', "2021-04-01") # type: str + 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_a_private_endpoint_connection_request_initial( @@ -1325,11 +1427,13 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsiste private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1376,21 +1480,26 @@ def begin_delete_a_private_endpoint_connection( # pylint: disable=inconsistent- :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_a_private_endpoint_connection_initial( + raw_result = self._delete_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1400,8 +1509,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1420,7 +1535,7 @@ def list_private_endpoint_connections( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List information about private endpoint connections under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1436,13 +1551,16 @@ def list_private_endpoint_connections( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - 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: @@ -1452,9 +1570,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=self.list_private_endpoint_connections.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1464,9 +1584,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disk_encryption_sets_operations.py index f57b0a90195d..9cd05c8b0002 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_list_associated_resources_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,58 +284,57 @@ def build_list_associated_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskEncryptionSetsOperations(object): - """DiskEncryptionSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -338,11 +346,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -372,9 +382,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -399,37 +409,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -446,17 +466,20 @@ def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -468,11 +491,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,9 +527,9 @@ def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -529,37 +554,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -578,7 +613,7 @@ def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -592,13 +627,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.DiskEncryptionSet] request = build_get_request( @@ -607,11 +645,13 @@ def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -638,13 +678,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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', "2021-04-01") # type: str + 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_initial( @@ -653,11 +696,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -701,20 +746,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -724,8 +774,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -743,7 +799,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -755,13 +811,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -770,9 +829,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -781,9 +842,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -820,7 +883,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -830,13 +893,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -844,9 +910,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -854,9 +922,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -895,7 +965,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> Iterable["_models.ResourceUriList"]: + ) -> Iterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -909,13 +979,16 @@ def list_associated_resources( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -925,9 +998,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -937,9 +1012,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disk_restore_point_operations.py index d57dc202d091..eda89d9be220 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disk_restore_point_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +37,12 @@ def build_get_request( disk_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,18 +56,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -76,9 +77,12 @@ def build_list_by_restore_point_request( vm_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints") # pylint: disable=line-too-long path_format_arguments = { @@ -91,18 +95,16 @@ def build_list_by_restore_point_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -114,14 +116,17 @@ def build_grant_access_request_initial( vm_restore_point_name: str, disk_restore_point_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -135,20 +140,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -163,9 +166,12 @@ def build_revoke_access_request_initial( disk_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -179,42 +185,38 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class DiskRestorePointOperations(object): - """DiskRestorePointOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskRestorePointOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -224,7 +226,7 @@ def get( vm_restore_point_name: str, disk_restore_point_name: str, **kwargs: Any - ) -> "_models.DiskRestorePoint": + ) -> _models.DiskRestorePoint: """Get disk restorePoint resource. :param resource_group_name: The name of the resource group. @@ -242,13 +244,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.DiskRestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.DiskRestorePoint] request = build_get_request( @@ -259,11 +264,13 @@ def get( disk_restore_point_name=disk_restore_point_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -291,7 +298,7 @@ def list_by_restore_point( restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> Iterable["_models.DiskRestorePointList"]: + ) -> Iterable[_models.DiskRestorePointList]: """Lists diskRestorePoints under a vmRestorePoint. :param resource_group_name: The name of the resource group. @@ -309,13 +316,16 @@ def list_by_restore_point( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskRestorePointList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePointList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePointList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -326,9 +336,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=self.list_by_restore_point.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -339,9 +351,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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,17 +394,20 @@ def _grant_access_initial( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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[Optional[_models.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -404,11 +421,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,9 +457,9 @@ def begin_grant_access( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a diskRestorePoint. :param resource_group_name: The name of the resource group. @@ -468,17 +487,20 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, @@ -487,20 +509,27 @@ def begin_grant_access( 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('AccessUri', 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( @@ -521,13 +550,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_restore_point_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', "2021-04-01") # type: str + 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_access_request_initial( @@ -538,11 +570,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_restore_point_name=disk_restore_point_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -592,22 +626,27 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, disk_restore_point_name=disk_restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -617,8 +656,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disks_operations.py index 910b14a8e7d7..96f47ccce812 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2021-04-01") # type: str + 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_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_images_operations.py index 5d4885584d7d..a73eed4b94e8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -155,9 +157,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +174,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -192,9 +195,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -205,18 +211,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +229,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -237,58 +244,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Image] _json = self._serialize.body(parameters, 'Image') @@ -300,11 +306,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -334,9 +342,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -357,37 +365,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -404,17 +422,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -426,11 +447,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -460,9 +483,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -483,37 +506,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -532,13 +565,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2021-04-01") # type: str + 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_initial( @@ -547,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,20 +631,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -616,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -637,7 +686,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -651,13 +700,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.Image] request = build_get_request( @@ -667,11 +719,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -707,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -722,9 +779,11 @@ def prepare_request(next_link=None): 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: @@ -733,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -772,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -781,13 +842,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -805,9 +871,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_log_analytics_operations.py index 7b7db65a6974..3edceac51737 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_operations.py index f0a49c926ccc..42b007289e35 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.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.compute.v2021_04_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_proximity_placement_groups_operations.py index 065139c2d344..c7b1881a05c1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( include_colocation_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +172,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if include_colocation_status is not None: - _query_parameters['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -189,9 +192,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -235,51 +242,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -293,14 +296,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -312,11 +318,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -346,9 +354,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -362,14 +370,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -381,11 +392,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -424,13 +437,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2021-04-01") # type: str + 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( @@ -439,11 +455,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -467,7 +485,7 @@ def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -482,13 +500,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.ProximityPlacementGroup] request = build_get_request( @@ -498,11 +519,13 @@ def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +550,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -537,13 +560,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -551,9 +577,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -561,9 +589,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -601,7 +631,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -613,13 +643,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -628,9 +661,11 @@ def prepare_request(next_link=None): 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: @@ -639,9 +674,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_restore_point_collections_operations.py index 207222700d22..52e6cf086511 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_restore_point_collections_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_restore_point_collections_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request( resource_group_name: str, restore_point_collection_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePointCollection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request( resource_group_name: str, restore_point_collection_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePointCollectionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( restore_point_collection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -161,9 +164,12 @@ def build_get_request( expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections") # pylint: disable=line-too-long path_format_arguments = { @@ -211,18 +218,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +236,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/restorePointCollections") path_format_arguments = { @@ -243,51 +251,47 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class RestorePointCollectionsOperations(object): - """RestorePointCollectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RestorePointCollectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollection", + parameters: _models.RestorePointCollection, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. @@ -304,14 +308,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollection') @@ -323,11 +330,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -357,9 +366,9 @@ def update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollectionUpdate", + parameters: _models.RestorePointCollectionUpdate, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. @@ -373,14 +382,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollectionUpdate') @@ -392,11 +404,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -423,13 +437,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -438,11 +455,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_name=restore_point_collection_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -485,20 +504,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -508,8 +532,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -529,7 +559,7 @@ def get( restore_point_collection_name: str, expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to get the restore point collection. :param resource_group_name: The name of the resource group. @@ -544,13 +574,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.RestorePointCollection] request = build_get_request( @@ -560,11 +593,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -590,7 +625,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.RestorePointCollectionListResult"]: + ) -> Iterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in a resource group. :param resource_group_name: The name of the resource group. @@ -602,13 +637,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -617,9 +655,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -628,9 +668,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -667,7 +709,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.RestorePointCollectionListResult"]: + ) -> Iterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in the subscription. Use nextLink property in the response to get the next page of restore point collections. Do this till nextLink is not null to fetch all the restore point collections. @@ -679,13 +721,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -693,9 +738,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -703,9 +750,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_restore_points_operations.py index 72ab3c70f913..8f9918a51c5e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_restore_points_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_restore_points_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_request_initial( restore_point_collection_name: str, restore_point_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePoint] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,9 +82,12 @@ def build_delete_request_initial( restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -96,18 +100,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -119,9 +121,12 @@ def build_get_request( restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,59 +139,58 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class RestorePointsOperations(object): - """RestorePointsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`restore_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_initial( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> "_models.RestorePoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] + ) -> _models.RestorePoint: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.RestorePoint] _json = self._serialize.body(parameters, 'RestorePoint') @@ -199,11 +203,13 @@ def _create_initial( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -230,9 +236,9 @@ def begin_create( resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> LROPoller["_models.RestorePoint"]: + ) -> LROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. @@ -257,17 +263,20 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.RestorePoint] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.RestorePoint] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] 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, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, @@ -275,20 +284,27 @@ def begin_create( 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('RestorePoint', 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( @@ -308,13 +324,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_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', "2021-04-01") # type: str + 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_initial( @@ -324,11 +343,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_name=restore_point_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -373,21 +394,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -397,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -418,7 +450,7 @@ def get( restore_point_collection_name: str, restore_point_name: str, **kwargs: Any - ) -> "_models.RestorePoint": + ) -> _models.RestorePoint: """The operation to get the restore point. :param resource_group_name: The name of the resource group. @@ -432,13 +464,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.RestorePoint] request = build_get_request( @@ -448,11 +483,13 @@ def get( restore_point_name=restore_point_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_snapshots_operations.py index ae0c5a8ef44a..9c1dd4f259a4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2021-04-01") # type: str + 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_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_ssh_public_keys_operations.py index 58b5bdd2e9f0..2d5cd65a4764 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_ssh_public_keys_operations.py @@ -16,12 +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 .. 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,9 +31,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") path_format_arguments = { @@ -43,18 +46,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -64,9 +65,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys") # pylint: disable=line-too-long path_format_arguments = { @@ -77,18 +81,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -98,14 +100,17 @@ def build_create_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -117,20 +122,18 @@ def build_create_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -142,14 +145,17 @@ def build_update_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyUpdateResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -161,20 +167,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -187,8 +191,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -200,13 +205,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -217,9 +221,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -231,18 +238,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -253,9 +258,12 @@ def build_generate_key_pair_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair") # pylint: disable=line-too-long path_format_arguments = { @@ -267,48 +275,44 @@ def build_generate_key_pair_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class SshPublicKeysOperations(object): - """SshPublicKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -319,13 +323,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -333,9 +340,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -343,9 +352,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -383,7 +394,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -396,13 +407,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -411,9 +425,11 @@ def prepare_request(next_link=None): 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: @@ -422,9 +438,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -462,9 +480,9 @@ def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -478,14 +496,17 @@ def create( :rtype: ~azure.mgmt.compute.v2021_04_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -497,11 +518,13 @@ def create( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -531,9 +554,9 @@ def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -547,14 +570,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_04_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -566,11 +592,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -609,13 +637,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -624,11 +655,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -651,7 +684,7 @@ def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -663,13 +696,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -678,11 +714,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -709,7 +747,7 @@ def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -723,13 +761,16 @@ def generate_key_pair( :rtype: ~azure.mgmt.compute.v2021_04_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -738,11 +779,13 @@ def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_usage_operations.py index d59e2e77a7d4..3e43a29ede51 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.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.compute.v2021_04_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_extension_images_operations.py index f7c3a375268c..75f923d814ad 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_extensions_operations.py index 5e4fb61d4dfb..9c7db5b00353 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,8 +129,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -141,13 +144,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -161,9 +163,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -176,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -202,9 +205,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -216,61 +222,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -283,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -318,9 +325,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -347,17 +354,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -365,20 +375,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -396,17 +413,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -419,11 +439,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,9 +472,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -479,17 +501,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -497,20 +522,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -530,13 +562,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -546,11 +581,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,21 +632,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -619,8 +661,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -641,7 +689,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -657,13 +705,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -674,11 +725,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -706,7 +759,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -720,13 +773,16 @@ def list( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineExtensionsListResult] request = build_list_request( @@ -736,11 +792,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_images_edge_zone_operations.py index b986c5fc9c7d..736aba1c300b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_images_edge_zone_operations.py @@ -15,6 +15,7 @@ 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 @@ -35,9 +36,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,18 +57,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -82,9 +84,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -99,24 +104,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -128,9 +131,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +149,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -165,9 +169,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -179,18 +186,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +208,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -219,42 +227,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesEdgeZoneOperations(object): - """VirtualMachineImagesEdgeZoneOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesEdgeZoneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -266,7 +270,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. @@ -286,13 +290,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineImage] request = build_get_request( @@ -305,11 +312,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -342,7 +351,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. @@ -369,13 +378,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -390,11 +402,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -422,7 +436,7 @@ def list_offers( edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. @@ -437,13 +451,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -453,11 +470,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -484,7 +503,7 @@ def list_publishers( location: str, edge_zone: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. @@ -496,13 +515,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -511,11 +533,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -544,7 +568,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. @@ -561,13 +585,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -578,11 +605,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_images_operations.py index a7a4620d1d09..028a7578f55c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_run_commands_operations.py index 60e68d70396c..712de12a99e8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -69,9 +70,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -83,18 +87,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -105,14 +107,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -125,20 +130,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -151,14 +154,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,20 +177,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -198,9 +202,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -213,18 +220,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -238,9 +243,12 @@ def build_get_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -253,20 +261,18 @@ def build_get_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -279,9 +285,12 @@ def build_list_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -293,51 +302,47 @@ def build_list_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -349,13 +354,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +372,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -375,9 +385,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -416,7 +428,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -428,13 +440,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.RunCommandDocument] request = build_get_request( @@ -443,11 +458,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -473,18 +490,21 @@ def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -497,11 +517,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,11 +554,11 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -548,7 +570,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -565,16 +587,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -582,20 +607,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -613,18 +645,21 @@ def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -637,11 +672,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -668,11 +705,11 @@ def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -683,7 +720,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -700,16 +737,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -717,20 +757,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -750,13 +797,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -766,11 +816,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,21 +867,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -839,8 +896,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -861,7 +924,7 @@ def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -877,13 +940,16 @@ def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -894,11 +960,13 @@ def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -926,7 +994,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -942,13 +1010,16 @@ def list_by_virtual_machine( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -959,9 +1030,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -972,9 +1045,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_extensions_operations.py index 3b2daef3cfbc..f99bf5333c79 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -345,17 +352,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -363,20 +373,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -394,17 +411,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -417,11 +437,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +474,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -481,17 +503,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -499,20 +524,27 @@ def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -532,13 +564,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2021-04-01") # type: str + 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_initial( @@ -548,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -597,21 +634,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -621,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -643,7 +691,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -659,13 +707,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineScaleSetExtension] request = build_get_request( @@ -676,11 +727,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -707,7 +760,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -721,13 +774,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -737,9 +793,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -749,9 +807,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 37fd7cfef5e7..df440ffd7950 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,8 +34,9 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -46,13 +48,12 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -63,8 +64,9 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -76,13 +78,12 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -93,8 +94,9 @@ def build_start_extension_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -106,13 +108,12 @@ def build_start_extension_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -123,9 +124,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -137,42 +141,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -180,13 +180,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2021-04-01") # type: str + 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_cancel_request_initial( @@ -195,11 +198,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,20 +246,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -264,8 +274,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -284,13 +300,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2021-04-01") # type: str + 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_start_os_upgrade_request_initial( @@ -299,11 +318,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,20 +368,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -370,8 +396,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -390,13 +422,16 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -405,11 +440,13 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -453,20 +490,25 @@ def begin_start_extension_upgrade( # pylint: disable=inconsistent-return-statem :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._start_extension_upgrade_initial( + raw_result = self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -476,8 +518,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -496,7 +544,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -508,13 +556,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -523,11 +574,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py index e66808c98c25..8f554f985aa5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -56,20 +59,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -83,14 +84,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -104,20 +108,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -132,9 +134,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -148,18 +153,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -174,9 +177,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -190,20 +196,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -217,9 +221,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -232,44 +239,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMExtensionsOperations(object): - """VirtualMachineScaleSetVMExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -277,17 +280,20 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -301,11 +307,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -368,17 +376,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -387,20 +398,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -419,17 +437,20 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -443,11 +464,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -475,9 +498,9 @@ def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -506,17 +529,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -525,20 +551,27 @@ def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -559,13 +592,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -576,11 +612,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -628,22 +666,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -653,8 +696,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -676,7 +725,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -694,13 +743,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -712,11 +764,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -745,7 +799,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -761,13 +815,16 @@ def list( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -778,11 +835,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index b7657fa663b9..a21390d8a212 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -133,9 +135,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -149,18 +154,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -175,9 +178,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -191,20 +197,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -218,9 +222,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -233,44 +240,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMRunCommandsOperations(object): - """VirtualMachineScaleSetVMRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -278,18 +281,21 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -303,11 +309,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -339,11 +347,11 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -356,7 +364,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -373,16 +381,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -423,18 +441,21 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,11 +503,11 @@ def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -497,7 +520,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -514,16 +537,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -532,20 +558,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -566,13 +599,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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', "2021-04-01") # type: str + 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_initial( @@ -583,11 +619,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,22 +673,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -660,8 +703,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -683,7 +732,7 @@ def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -701,13 +750,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineRunCommand] request = build_get_request( @@ -719,11 +771,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -752,7 +806,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -770,13 +824,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -788,9 +845,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -802,9 +861,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_vms_operations.py index 69ab6062ff2e..6328bdcfdcab 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,13 +35,15 @@ def build_reimage_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -54,19 +56,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,8 +80,9 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -94,13 +95,12 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -112,8 +112,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -126,13 +127,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -143,14 +143,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -163,20 +166,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -192,8 +193,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -206,15 +208,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -228,9 +229,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -243,20 +247,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -268,9 +270,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -283,18 +288,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -309,9 +312,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -323,24 +329,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -354,8 +358,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -368,15 +373,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -388,8 +392,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -402,13 +407,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -420,8 +424,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -434,13 +439,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -452,8 +456,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -466,13 +471,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -486,9 +490,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -501,20 +508,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -526,8 +531,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -540,13 +546,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -558,8 +563,9 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -572,13 +578,12 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -589,14 +594,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -609,63 +617,62 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -681,11 +688,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -708,7 +717,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -735,17 +744,20 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -753,6 +765,8 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -762,8 +776,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -783,13 +803,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-04-01") # type: str + 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_reimage_all_request_initial( @@ -799,11 +822,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -849,21 +874,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -873,8 +903,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -894,13 +930,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-04-01") # type: str + 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_deallocate_request_initial( @@ -910,11 +949,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -961,21 +1002,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -985,8 +1031,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1004,17 +1056,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -1027,11 +1082,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1062,9 +1119,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1090,17 +1147,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1108,20 +1168,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1142,13 +1209,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1159,11 +1229,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1212,22 +1284,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1237,8 +1314,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1259,7 +1342,7 @@ def get( instance_id: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1277,13 +1360,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1294,11 +1380,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1326,7 +1414,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1340,13 +1428,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1356,11 +1447,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1390,7 +1483,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1414,13 +1507,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1433,9 +1529,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1448,9 +1546,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1491,13 +1591,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2021-04-01") # type: str + 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_power_off_request_initial( @@ -1508,11 +1611,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1564,22 +1669,27 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1589,8 +1699,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1610,13 +1726,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1626,11 +1745,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1675,21 +1796,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1699,8 +1825,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1720,13 +1852,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-04-01") # type: str + 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_start_request_initial( @@ -1736,11 +1871,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1785,21 +1922,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1809,8 +1951,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1830,13 +1978,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-04-01") # type: str + 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_redeploy_request_initial( @@ -1846,11 +1997,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1896,21 +2049,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1920,8 +2078,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1942,7 +2106,7 @@ def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -1961,13 +2125,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1978,11 +2145,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2010,13 +2179,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2026,11 +2198,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2075,21 +2249,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2099,8 +2278,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2134,13 +2319,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2150,11 +2338,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2176,18 +2366,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2200,11 +2393,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2233,11 +2428,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2248,7 +2443,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_04_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2264,16 +2459,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2281,20 +2479,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_sets_operations.py index df2ff018b161..ab27637943f1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -159,8 +162,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,15 +176,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -193,9 +196,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -207,20 +213,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -230,13 +234,15 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -248,19 +254,17 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -272,14 +276,16 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -291,21 +297,19 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -318,9 +322,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -332,18 +339,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -353,9 +358,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -366,18 +374,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -386,9 +392,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -398,18 +407,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -420,9 +427,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -434,18 +444,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -456,9 +464,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -470,18 +481,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -491,14 +500,16 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -510,21 +521,19 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -536,13 +545,15 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -554,19 +565,17 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -578,13 +587,15 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -596,19 +607,17 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -620,13 +629,15 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -638,19 +649,17 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -662,13 +671,15 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -680,19 +691,17 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -704,13 +713,15 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -722,19 +733,17 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -746,13 +755,15 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -764,19 +775,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -788,13 +797,15 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -806,19 +817,17 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -833,9 +842,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( platform_update_domain: int, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -847,19 +859,17 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -869,13 +879,15 @@ def build_convert_to_single_placement_group_request( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VMScaleSetConvertToSinglePlacementGroupInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup") # pylint: disable=line-too-long path_format_arguments = { @@ -887,19 +899,17 @@ def build_convert_to_single_placement_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -911,13 +921,15 @@ def build_set_orchestration_service_state_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.OrchestrationServiceStateInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState") # pylint: disable=line-too-long path_format_arguments = { @@ -929,52 +941,48 @@ def build_set_orchestration_service_state_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. @@ -986,13 +994,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1001,9 +1012,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -1012,9 +1025,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1051,17 +1066,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -1073,11 +1091,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1107,9 +1127,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1132,37 +1152,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1179,17 +1209,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -1201,11 +1234,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1231,9 +1266,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1256,37 +1291,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1306,13 +1351,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1322,11 +1370,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1372,21 +1422,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1396,8 +1451,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1417,7 +1478,7 @@ def get( vm_scale_set_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1433,13 +1494,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineScaleSet] request = build_get_request( @@ -1449,11 +1513,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1478,17 +1544,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1503,11 +1572,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1529,7 +1600,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1556,23 +1627,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1582,8 +1658,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1600,18 +1682,21 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1624,11 +1709,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements json=_json, force_deletion=force_deletion, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1650,7 +1737,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: @@ -1678,17 +1765,20 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, @@ -1696,6 +1786,8 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1705,8 +1797,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1725,7 +1823,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1737,13 +1835,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1752,11 +1853,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1782,7 +1885,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1794,13 +1897,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1809,9 +1915,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1820,9 +1928,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1859,7 +1969,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1871,13 +1981,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1885,9 +1998,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1895,9 +2010,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1936,7 +2053,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1951,13 +2068,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1967,9 +2087,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1979,9 +2101,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2020,7 +2144,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -2034,13 +2158,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2050,9 +2177,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2062,9 +2191,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2102,17 +2233,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2128,11 +2262,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2155,7 +2291,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -2186,17 +2322,20 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -2204,6 +2343,8 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2213,8 +2354,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2231,17 +2378,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2256,11 +2406,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2282,7 +2434,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2307,23 +2459,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2333,8 +2490,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2351,17 +2514,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2376,11 +2542,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2402,7 +2570,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2427,23 +2595,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2453,8 +2626,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2471,17 +2650,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2496,11 +2678,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2522,7 +2706,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2548,23 +2732,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2574,8 +2763,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2592,17 +2787,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2617,11 +2815,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2643,7 +2843,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2671,23 +2871,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2697,8 +2902,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2715,17 +2926,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2737,11 +2951,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2763,7 +2979,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2787,23 +3003,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2813,8 +3034,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2831,17 +3058,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -2856,11 +3086,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2882,7 +3114,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -2908,23 +3140,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2934,8 +3171,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2952,17 +3195,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2977,11 +3223,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3003,7 +3251,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -3029,23 +3277,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -3055,8 +3308,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -3076,7 +3335,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -3092,13 +3351,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -3108,11 +3370,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3138,7 +3402,7 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -3155,14 +3419,17 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st :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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -3174,11 +3441,13 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3199,17 +3468,20 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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[None] _json = self._serialize.body(parameters, 'OrchestrationServiceStateInput') @@ -3221,11 +3493,13 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3247,7 +3521,7 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> LROPoller[None]: """Changes ServiceState property for a given service. @@ -3270,23 +3544,28 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + 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._set_orchestration_service_state_initial( + raw_result = self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -3296,8 +3575,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_sizes_operations.py index 4db22fb3ae12..accacd0b1fdd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -99,13 +99,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machines_operations.py index bffe942c53e9..fd824ef44e9d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_04_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -203,8 +207,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -216,15 +221,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -237,9 +241,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -251,20 +258,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -275,9 +280,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -289,18 +297,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -311,8 +317,9 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -324,13 +331,12 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -341,8 +347,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -354,13 +361,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -371,8 +377,9 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -384,13 +391,12 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -400,9 +406,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -413,18 +422,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -435,9 +442,12 @@ def build_list_all_request( status_only: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -447,20 +457,18 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 status_only is not None: - _query_parameters['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') + _params['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -471,9 +479,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -485,18 +496,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -509,8 +518,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -522,15 +532,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -541,9 +550,12 @@ def build_reapply_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply") # pylint: disable=line-too-long path_format_arguments = { @@ -555,18 +567,16 @@ def build_reapply_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -577,8 +587,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -590,13 +601,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -607,8 +617,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -620,13 +631,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -637,8 +647,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -650,13 +661,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -666,13 +676,15 @@ def build_reimage_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -684,19 +696,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -711,9 +721,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -725,20 +738,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -749,8 +760,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -762,13 +774,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -779,8 +790,9 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _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.Compute/virtualMachines/{vmName}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -792,13 +804,12 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -809,9 +820,12 @@ def build_assess_patches_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -823,18 +837,16 @@ def build_assess_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -844,14 +856,17 @@ def build_install_patches_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineInstallPatchesParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -863,20 +878,18 @@ def build_install_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -888,14 +901,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -907,53 +923,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.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.compute.v2021_04_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -965,13 +977,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -980,9 +995,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -991,9 +1008,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1030,17 +1049,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -1052,11 +1074,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1084,9 +1108,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -1110,37 +1134,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -1157,17 +1191,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -1179,11 +1216,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1213,9 +1252,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -1238,37 +1277,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1285,17 +1334,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1307,11 +1359,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1337,9 +1391,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1361,37 +1415,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1411,13 +1475,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1427,11 +1494,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1477,21 +1546,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1501,8 +1575,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1522,7 +1602,7 @@ def get( vm_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1540,13 +1620,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachine] request = build_get_request( @@ -1556,11 +1639,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1587,7 +1672,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1599,13 +1684,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2021_04_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # 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.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1614,11 +1702,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1645,13 +1735,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1660,11 +1753,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1707,20 +1802,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1730,8 +1830,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1750,13 +1856,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-04-01") # type: str + 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_deallocate_request_initial( @@ -1765,11 +1874,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1812,20 +1923,25 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1835,8 +1951,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1872,13 +1994,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1887,11 +2012,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1913,7 +2040,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1926,13 +2053,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1941,9 +2071,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1952,9 +2084,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1992,7 +2126,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -2006,13 +2140,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2021,9 +2158,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2032,9 +2171,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2073,7 +2214,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -2088,13 +2229,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2104,9 +2248,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2116,9 +2262,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2158,13 +2306,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -2174,11 +2325,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2226,21 +2379,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2250,8 +2408,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2270,13 +2434,16 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-04-01") # type: str + 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_reapply_request_initial( @@ -2285,11 +2452,13 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2331,20 +2500,25 @@ def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._reapply_initial( + raw_result = self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2354,8 +2528,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2374,13 +2554,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2389,11 +2572,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2435,20 +2620,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2458,8 +2648,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2478,13 +2674,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2493,11 +2692,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2539,20 +2740,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2562,8 +2768,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2582,13 +2794,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2597,11 +2812,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2643,20 +2860,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2666,8 +2888,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2684,17 +2912,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -2709,11 +2940,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2735,7 +2968,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -2759,23 +2992,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -2785,8 +3023,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2806,7 +3050,7 @@ def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -2822,13 +3066,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_04_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -2838,11 +3085,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2869,13 +3118,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2884,11 +3136,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2930,20 +3184,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2953,8 +3212,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2985,13 +3250,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -3000,11 +3268,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3026,14 +3296,17 @@ def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -3042,11 +3315,13 @@ def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3075,7 +3350,7 @@ def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -3096,34 +3371,44 @@ def begin_assess_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -3140,17 +3425,20 @@ def _install_patches_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineInstallPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineInstallPatchesResult"]] + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - 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.VirtualMachineInstallPatchesResult]] _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') @@ -3162,11 +3450,13 @@ def _install_patches_initial( content_type=content_type, json=_json, template_url=self._install_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3194,9 +3484,9 @@ def begin_install_patches( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineInstallPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. @@ -3220,37 +3510,47 @@ def begin_install_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.VirtualMachineInstallPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.VirtualMachineInstallPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstallPatchesResult"] 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._install_patches_initial( + raw_result = self._install_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineInstallPatchesResult', 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( @@ -3267,18 +3567,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -3290,11 +3593,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3322,11 +3627,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -3335,7 +3640,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_04_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -3351,36 +3656,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_04_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_compute_management_client.py index e79f9a5f3db6..2c8e649027cf 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_compute_management_client.py @@ -162,45 +162,123 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_point_collections = RestorePointCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservation_groups = CapacityReservationGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservations = CapacityReservationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_sharing_profile = GallerySharingProfileOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_galleries = SharedGalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_gallery_images = SharedGalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.community_galleries = CommunityGalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.community_gallery_images = CommunityGalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_point_collections = RestorePointCollectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_points = RestorePointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservations = CapacityReservationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.resource_skus = ResourceSkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_sharing_profile = GallerySharingProfileOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_galleries = SharedGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_images = SharedGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_galleries = CommunityGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_gallery_images = CommunityGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/_compute_management_client.py index 98e739578f26..1ff515fb326b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/_compute_management_client.py @@ -165,45 +165,123 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_point_collections = RestorePointCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservation_groups = CapacityReservationGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservations = CapacityReservationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.resource_skus = ResourceSkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_sharing_profile = GallerySharingProfileOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_galleries = SharedGalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_gallery_images = SharedGalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.community_galleries = CommunityGalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.community_gallery_images = CommunityGalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_point_collections = RestorePointCollectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_points = RestorePointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservations = CapacityReservationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.resource_skus = ResourceSkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_sharing_profile = GallerySharingProfileOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_galleries = SharedGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_images = SharedGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_galleries = CommunityGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_gallery_images = CommunityGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/__init__.py index cca9cf86cf8d..6265718bd8a6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/__init__.py @@ -46,6 +46,9 @@ from ._community_gallery_images_operations import CommunityGalleryImagesOperations from ._community_gallery_image_versions_operations import CommunityGalleryImageVersionsOperations +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', 'AvailabilitySetsOperations', @@ -87,3 +90,5 @@ 'CommunityGalleryImagesOperations', 'CommunityGalleryImageVersionsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_availability_sets_operations.py index 6baaaa4275be..3141478f286d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_capacity_reservation_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_capacity_reservation_groups_operations.py index 0ab6fc360a33..dc06c188a649 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_capacity_reservation_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_capacity_reservation_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CapacityReservationGroupsOperations: - """CapacityReservationGroupsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroup", + parameters: _models.CapacityReservationGroup, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details. @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroupUpdate", + parameters: _models.CapacityReservationGroupUpdate, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. @@ -138,14 +142,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroupUpdate') @@ -157,11 +164,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -203,13 +212,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -218,11 +230,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,7 +260,7 @@ async def get( capacity_reservation_group_name: str, expand: Optional[Union[str, "_models.CapacityReservationGroupInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation that retrieves information about a capacity reservation group. :param resource_group_name: The name of the resource group. @@ -264,13 +278,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] request = build_get_request( @@ -280,11 +297,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationGroupListResult"]: + ) -> AsyncIterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -329,13 +348,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -345,9 +367,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, 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: @@ -357,9 +381,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 +423,7 @@ def list_by_subscription( self, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationGroupListResult"]: + ) -> AsyncIterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -413,13 +439,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -428,9 +457,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -439,9 +470,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_capacity_reservations_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_capacity_reservations_operations.py index c0e073b1f375..a4d42a1df5f2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_capacity_reservations_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_capacity_reservations_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CapacityReservationsOperations: - """CapacityReservationsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`capacity_reservations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> "_models.CapacityReservation": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] + ) -> _models.CapacityReservation: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] _json = self._serialize.body(parameters, 'CapacityReservation') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> AsyncLROPoller["_models.CapacityReservation"]: + ) -> AsyncLROPoller[_models.CapacityReservation]: """The operation to create or update a capacity reservation. Please note some properties can be set only during capacity reservation creation. Please refer to https://aka.ms/CapacityReservation for more details. @@ -139,17 +143,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -157,20 +164,27 @@ async def begin_create_or_update( 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('CapacityReservation', 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( @@ -188,17 +202,20 @@ async def _update_initial( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> Optional["_models.CapacityReservation"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CapacityReservation"]] + ) -> Optional[_models.CapacityReservation]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.CapacityReservation]] _json = self._serialize.body(parameters, 'CapacityReservationUpdate') @@ -211,11 +228,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -244,9 +263,9 @@ async def begin_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.CapacityReservation"]: + ) -> AsyncLROPoller[_models.CapacityReservation]: """The operation to update a capacity reservation. :param resource_group_name: The name of the resource group. @@ -271,17 +290,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -289,20 +311,27 @@ async def begin_update( 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('CapacityReservation', 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( @@ -322,13 +351,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements capacity_reservation_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -338,11 +370,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -389,21 +423,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -413,8 +452,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -435,7 +480,7 @@ async def get( capacity_reservation_name: str, expand: Optional[Union[str, "_models.CapacityReservationInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservation": + ) -> _models.CapacityReservation: """The operation that retrieves information about the capacity reservation. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list_by_capacity_reservation_group( resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationListResult"]: + ) -> AsyncIterable[_models.CapacityReservationListResult]: """Lists all of the capacity reservations in the specified capacity reservation group. Use the nextLink property in the response to get the next page of capacity reservations. @@ -517,13 +567,16 @@ def list_by_capacity_reservation_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.CapacityReservationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -533,9 +586,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_capacity_reservation_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: @@ -545,9 +600,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_community_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_community_galleries_operations.py index a0fc195eb596..8d5000aae0d1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_community_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_community_galleries_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CommunityGalleriesOperations: - """CommunityGalleriesOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`community_galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -49,7 +48,7 @@ async def get( location: str, public_gallery_name: str, **kwargs: Any - ) -> "_models.CommunityGallery": + ) -> _models.CommunityGallery: """Get a community gallery by gallery public name. :param location: Resource location. @@ -61,13 +60,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CommunityGallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGallery] request = build_get_request( @@ -76,11 +78,13 @@ async def get( public_gallery_name=public_gallery_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_community_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_community_gallery_image_versions_operations.py index 0da4c9a3d1c5..f5fce91c761b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_community_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_community_gallery_image_versions_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CommunityGalleryImageVersionsOperations: - """CommunityGalleryImageVersionsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`community_gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any - ) -> "_models.CommunityGalleryImageVersion": + ) -> _models.CommunityGalleryImageVersion: """Get a community gallery image version. :param location: Resource location. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CommunityGalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGalleryImageVersion] request = build_get_request( @@ -87,11 +89,13 @@ async def get( gallery_image_version_name=gallery_image_version_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_community_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_community_gallery_images_operations.py index 4bdb5ae31859..3d6ee80062ee 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_community_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_community_gallery_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CommunityGalleryImagesOperations: - """CommunityGalleryImagesOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`community_gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -50,7 +49,7 @@ async def get( public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.CommunityGalleryImage": + ) -> _models.CommunityGalleryImage: """Get a community gallery image. :param location: Resource location. @@ -64,13 +63,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CommunityGalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGalleryImage] request = build_get_request( @@ -80,11 +82,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_dedicated_host_groups_operations.py index bb2a074bf29c..e0c886d0b831 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_dedicated_host_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostGroupsOperations: - """DedicatedHostGroupsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -137,14 +141,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -156,11 +163,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -199,13 +208,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,11 +226,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +256,7 @@ async def get( host_group_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -258,13 +272,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -274,11 +291,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +323,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -317,13 +336,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -332,9 +354,11 @@ def prepare_request(next_link=None): 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: @@ -343,9 +367,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -382,7 +408,7 @@ async def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -393,13 +419,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -407,9 +436,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -417,9 +448,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_dedicated_hosts_operations.py index d0f677a13a53..f8e3e01040a8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostsOperations: - """DedicatedHostsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('DedicatedHost', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -267,17 +286,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -285,20 +307,27 @@ async def begin_update( 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('DedicatedHost', 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( @@ -318,13 +347,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -334,11 +366,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,21 +417,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -407,8 +446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -429,7 +474,7 @@ async def get( host_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -495,7 +545,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostListResult"]: + ) -> AsyncIterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -510,13 +560,16 @@ def list_by_host_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -526,9 +579,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -538,9 +593,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_galleries_operations.py index 468987177272..ea2f2b3a4490 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleriesOperations: - """GalleriesOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'GalleryUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -234,9 +253,9 @@ async def begin_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -259,37 +278,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -309,7 +338,7 @@ async def get( gallery_name: str, select: Optional[Union[str, "_models.SelectPermissions"]] = None, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -339,11 +371,13 @@ async def get( api_version=api_version, select=select, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -370,13 +404,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -385,11 +422,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -431,20 +470,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -454,8 +498,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -473,7 +523,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -484,13 +534,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +552,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -510,9 +565,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -549,7 +606,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -558,13 +615,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -572,9 +632,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -582,9 +644,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_application_versions_operations.py index e9f2b4f5ffc1..648cab3d4cde 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationVersionsOperations: - """GalleryApplicationVersionsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -152,17 +156,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -171,20 +178,27 @@ async def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -203,17 +217,20 @@ async def _update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersionUpdate') @@ -227,11 +244,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -259,9 +278,9 @@ async def begin_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -295,17 +314,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -314,20 +336,27 @@ async def begin_update( 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('GalleryApplicationVersion', 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( @@ -349,7 +378,7 @@ async def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -370,13 +399,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -388,11 +420,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -421,13 +455,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -438,11 +475,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -493,22 +532,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -518,8 +562,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -539,7 +589,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationVersionList"]: + ) -> AsyncIterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -557,13 +607,16 @@ def list_by_gallery_application( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -574,9 +627,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -587,9 +642,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_applications_operations.py index cd19cfc3fcf1..4b34295edaba 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationsOperations: - """GalleryApplicationsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -144,17 +148,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -162,20 +169,27 @@ async def begin_create_or_update( 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('GalleryApplication', 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( @@ -193,17 +207,20 @@ async def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplicationUpdate') @@ -216,11 +233,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -277,17 +296,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -295,20 +317,27 @@ async def begin_update( 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('GalleryApplication', 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( @@ -328,7 +357,7 @@ async def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -344,13 +373,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -360,11 +392,13 @@ async def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,13 +426,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -408,11 +445,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,21 +497,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -482,8 +526,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -502,7 +552,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationList"]: + ) -> AsyncIterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -517,13 +567,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -533,9 +586,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -545,9 +600,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_image_versions_operations.py index 97729da4853d..93d583dce77c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImageVersionsOperations: - """GalleryImageVersionsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Create or update a gallery image version. :param resource_group_name: The name of the resource group. @@ -151,17 +155,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -170,20 +177,27 @@ async def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -202,17 +216,20 @@ async def _update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersionUpdate') @@ -226,11 +243,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -258,9 +277,9 @@ async def begin_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Update a gallery image version. :param resource_group_name: The name of the resource group. @@ -293,17 +312,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -312,20 +334,27 @@ async def begin_update( 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('GalleryImageVersion', 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( @@ -347,7 +376,7 @@ async def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery image version. :param resource_group_name: The name of the resource group. @@ -367,13 +396,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -385,11 +417,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -418,13 +452,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -435,11 +472,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -489,22 +528,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -514,8 +558,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -535,7 +585,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageVersionList"]: + ) -> AsyncIterable[_models.GalleryImageVersionList]: """List gallery image versions in a gallery image definition. :param resource_group_name: The name of the resource group. @@ -553,13 +603,16 @@ def list_by_gallery_image( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +623,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +638,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_images_operations.py index 2ad5b2a4c108..8a34c53ea80c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImagesOperations: - """GalleryImagesOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Create or update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -160,20 +167,27 @@ async def begin_create_or_update( 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('GalleryImage', 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( @@ -191,17 +205,20 @@ async def _update_initial( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImageUpdate') @@ -214,11 +231,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -245,9 +264,9 @@ async def begin_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -274,17 +293,20 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -292,20 +314,27 @@ async def begin_update( 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('GalleryImage', 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( @@ -325,7 +354,7 @@ async def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery image definition. :param resource_group_name: The name of the resource group. @@ -340,13 +369,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -356,11 +388,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -388,13 +422,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -404,11 +441,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -454,21 +493,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -478,8 +522,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -498,7 +548,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageList"]: + ) -> AsyncIterable[_models.GalleryImageList]: """List gallery image definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -512,13 +562,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -528,9 +581,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -540,9 +595,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_sharing_profile_operations.py index c2ef650450ca..4c9b00fc5a6c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_sharing_profile_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_gallery_sharing_profile_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,42 +25,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GallerySharingProfileOperations: - """GallerySharingProfileOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`gallery_sharing_profile` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _update_initial( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> "_models.SharingUpdate": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] + ) -> _models.SharingUpdate: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharingUpdate] _json = self._serialize.body(sharing_update, 'SharingUpdate') @@ -71,11 +73,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,9 +109,9 @@ async def begin_update( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.SharingUpdate"]: + ) -> AsyncLROPoller[_models.SharingUpdate]: """Update sharing profile of a gallery. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.SharingUpdate] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharingUpdate] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, sharing_update=sharing_update, 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('SharingUpdate', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_images_operations.py index 68896c13c350..ddb3d417b084 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_log_analytics_operations.py index 2be71778a1a4..65668d3a6235 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_operations.py index 1dd1140ba1a8..784759633693 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_proximity_placement_groups_operations.py index 3cb6bfa80b51..87cae38a40cb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,7 +254,7 @@ async def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -255,13 +269,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -271,11 +288,13 @@ async def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -300,7 +319,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -310,13 +329,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -324,9 +346,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -334,9 +358,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -374,7 +400,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -386,13 +412,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,9 +430,11 @@ def prepare_request(next_link=None): 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: @@ -412,9 +443,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_resource_skus_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_resource_skus_operations.py index 0be74dc6031a..60f971b4a179 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_resource_skus_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_resource_skus_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +24,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ResourceSkusOperations: - """ResourceSkusOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`resource_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( @@ -50,7 +49,7 @@ def list( filter: Optional[str] = None, include_extended_locations: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ResourceSkusResult"]: + ) -> AsyncIterable[_models.ResourceSkusResult]: """Gets the list of Microsoft.Compute SKUs available for your Subscription. :param filter: The filter to apply on the operation. Only **location** filter is supported @@ -65,13 +64,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.ResourceSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +83,11 @@ def prepare_request(next_link=None): filter=filter, include_extended_locations=include_extended_locations, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -93,9 +97,11 @@ def prepare_request(next_link=None): filter=filter, include_extended_locations=include_extended_locations, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_restore_point_collections_operations.py index 4e82d34d8911..1b6a6e446630 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_restore_point_collections_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_restore_point_collections_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,35 +27,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RestorePointCollectionsOperations: - """RestorePointCollectionsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollection", + parameters: _models.RestorePointCollection, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. @@ -71,14 +70,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollection') @@ -90,11 +92,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,9 +128,9 @@ async def update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollectionUpdate", + parameters: _models.RestorePointCollectionUpdate, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. @@ -140,14 +144,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollectionUpdate') @@ -159,11 +166,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -190,13 +199,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -205,11 +217,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_name=restore_point_collection_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -252,20 +266,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -275,8 +294,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -296,7 +321,7 @@ async def get( restore_point_collection_name: str, expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to get the restore point collection. :param resource_group_name: The name of the resource group. @@ -311,13 +336,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] request = build_get_request( @@ -327,11 +355,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -357,7 +387,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.RestorePointCollectionListResult"]: + ) -> AsyncIterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in a resource group. :param resource_group_name: The name of the resource group. @@ -369,13 +399,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -384,9 +417,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -395,9 +430,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -434,7 +471,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.RestorePointCollectionListResult"]: + ) -> AsyncIterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in the subscription. Use nextLink property in the response to get the next page of restore point collections. Do this till nextLink is not null to fetch all the restore point collections. @@ -446,13 +483,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -460,9 +500,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -470,9 +512,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_restore_points_operations.py index afeffc3397ea..537ed8f779e9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_restore_points_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_restore_points_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RestorePointsOperations: - """RestorePointsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`restore_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_initial( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> "_models.RestorePoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] + ) -> _models.RestorePoint: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] _json = self._serialize.body(parameters, 'RestorePoint') @@ -73,11 +75,13 @@ async def _create_initial( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -104,9 +108,9 @@ async def begin_create( resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> AsyncLROPoller["_models.RestorePoint"]: + ) -> AsyncLROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. @@ -131,17 +135,20 @@ async def begin_create( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.RestorePoint] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] 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, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, @@ -149,20 +156,27 @@ async def begin_create( 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('RestorePoint', 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( @@ -182,13 +196,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -198,11 +215,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_name=restore_point_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,21 +266,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -271,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -292,7 +322,7 @@ async def get( restore_point_collection_name: str, restore_point_name: str, **kwargs: Any - ) -> "_models.RestorePoint": + ) -> _models.RestorePoint: """The operation to get the restore point. :param resource_group_name: The name of the resource group. @@ -306,13 +336,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] request = build_get_request( @@ -322,11 +355,13 @@ async def get( restore_point_name=restore_point_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_shared_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_shared_galleries_operations.py index 68b716a2202f..e0ca85806d97 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_shared_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_shared_galleries_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SharedGalleriesOperations: - """SharedGalleriesOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`shared_galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -51,7 +50,7 @@ def list( location: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.SharedGalleryList"]: + ) -> AsyncIterable[_models.SharedGalleryList]: """List shared galleries by subscription id or tenant id. :param location: Resource location. @@ -65,13 +64,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.SharedGalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +83,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -93,9 +97,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +140,7 @@ async def get( location: str, gallery_unique_name: str, **kwargs: Any - ) -> "_models.SharedGallery": + ) -> _models.SharedGallery: """Get a shared gallery by subscription id or tenant id. :param location: Resource location. @@ -146,13 +152,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SharedGallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGallery] request = build_get_request( @@ -161,11 +170,13 @@ async def get( gallery_unique_name=gallery_unique_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_shared_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_shared_gallery_image_versions_operations.py index e70e9d3895a0..8942a88ddcc1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_shared_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_shared_gallery_image_versions_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SharedGalleryImageVersionsOperations: - """SharedGalleryImageVersionsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`shared_gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -53,7 +52,7 @@ def list( gallery_image_name: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.SharedGalleryImageVersionList"]: + ) -> AsyncIterable[_models.SharedGalleryImageVersionList]: """List shared gallery image versions by subscription id or tenant id. :param location: Resource location. @@ -73,13 +72,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +93,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_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,9 +109,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -148,7 +154,7 @@ async def get( gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any - ) -> "_models.SharedGalleryImageVersion": + ) -> _models.SharedGalleryImageVersion: """Get a shared gallery image version by subscription id or tenant id. :param location: Resource location. @@ -168,13 +174,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageVersion] request = build_get_request( @@ -185,11 +194,13 @@ async def get( gallery_image_version_name=gallery_image_version_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_shared_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_shared_gallery_images_operations.py index 42f08e0f27c7..fecae1869d5d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_shared_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_shared_gallery_images_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SharedGalleryImagesOperations: - """SharedGalleryImagesOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`shared_gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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 +51,7 @@ def list( gallery_unique_name: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.SharedGalleryImageList"]: + ) -> AsyncIterable[_models.SharedGalleryImageList]: """List shared gallery images by subscription id or tenant id. :param location: Resource location. @@ -69,13 +68,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -86,9 +88,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -99,9 +103,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -141,7 +147,7 @@ async def get( gallery_unique_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.SharedGalleryImage": + ) -> _models.SharedGalleryImage: """Get a shared gallery image by subscription id or tenant id. :param location: Resource location. @@ -156,13 +162,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImage] request = build_get_request( @@ -172,11 +181,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_ssh_public_keys_operations.py index fb0a4867909a..4926b2d7e96c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_ssh_public_keys_operations.py @@ -15,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 @@ -24,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SshPublicKeysOperations: - """SshPublicKeysOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -60,13 +59,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -74,9 +76,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -84,9 +88,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +130,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -137,13 +143,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -152,9 +161,11 @@ def prepare_request(next_link=None): 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: @@ -163,9 +174,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -203,9 +216,9 @@ async def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -219,14 +232,17 @@ async def create( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -238,11 +254,13 @@ async def create( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -272,9 +290,9 @@ async def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -288,14 +306,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -307,11 +328,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -350,13 +373,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -365,11 +391,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,7 +420,7 @@ async def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -404,13 +432,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -419,11 +450,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,7 +483,7 @@ async def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -464,13 +497,16 @@ async def generate_key_pair( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -479,11 +515,13 @@ async def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_usage_operations.py index ae49b5adfdc0..925cc55ce036 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_extension_images_operations.py index 54284f5251a2..46010662c0c6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_extensions_operations.py index bd57951736f4..c73e8e540708 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_images_edge_zone_operations.py index 8c2c5df7f220..8c4bae533346 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_images_edge_zone_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesEdgeZoneOperations: - """VirtualMachineImagesEdgeZoneOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +52,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. @@ -73,13 +72,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -92,11 +94,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -129,7 +133,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. @@ -156,13 +160,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -177,11 +184,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -209,7 +218,7 @@ async def list_offers( edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. @@ -224,13 +233,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -240,11 +252,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -271,7 +285,7 @@ async def list_publishers( location: str, edge_zone: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. @@ -283,13 +297,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -298,11 +315,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -331,7 +350,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. @@ -348,13 +367,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -365,11 +387,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_images_operations.py index ccfa60dd52fb..24ecf7783859 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_run_commands_operations.py index 13debd18011e..c740540d7bf9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -64,13 +63,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,7 +137,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -143,13 +149,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -158,11 +167,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,18 +199,21 @@ async def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -212,11 +226,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,11 +263,11 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -263,7 +279,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -280,16 +296,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -297,20 +316,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -328,18 +354,21 @@ async def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -352,11 +381,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,11 +414,11 @@ async def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -398,7 +429,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -415,16 +446,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -432,20 +466,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -465,13 +506,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -481,11 +525,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,21 +576,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -554,8 +605,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -576,7 +633,7 @@ async def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -592,13 +649,16 @@ async def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -609,11 +669,13 @@ async def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -641,7 +703,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -657,13 +719,16 @@ def list_by_virtual_machine( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -674,9 +739,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -687,9 +754,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index db4a0bc1ffa9..e6d146758ecb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -189,17 +203,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -212,11 +229,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -276,17 +295,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -294,20 +316,27 @@ async def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -327,13 +356,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -343,11 +375,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,21 +426,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -416,8 +455,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -438,7 +483,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -516,13 +566,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -532,9 +585,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -544,9 +599,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 7e79a289d931..a5f451a08225 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,13 +292,16 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu vm_scale_set_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -276,11 +310,13 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,20 +360,25 @@ async def begin_start_extension_upgrade( # pylint: disable=inconsistent-return- :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_extension_upgrade_initial( + raw_result = await self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -347,8 +388,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -367,7 +414,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -379,13 +426,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -394,11 +444,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py index c64a50721a01..13744df017cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMExtensionsOperations: - """VirtualMachineScaleSetVMExtensionsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -51,17 +50,20 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -111,9 +115,9 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -161,20 +168,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -193,17 +207,20 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -217,11 +234,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -249,9 +268,9 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -280,17 +299,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -299,20 +321,27 @@ async def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -333,13 +362,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -350,11 +382,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -402,22 +436,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -427,8 +466,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -450,7 +495,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -468,13 +513,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -486,11 +534,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -519,7 +569,7 @@ async def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -535,13 +585,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -552,11 +605,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index ce88e6216c89..927587058c59 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMRunCommandsOperations: - """VirtualMachineScaleSetVMRunCommandsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,18 +52,21 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -78,11 +80,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -114,11 +118,11 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -131,7 +135,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -148,16 +152,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -166,20 +173,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -198,18 +212,21 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -223,11 +240,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,11 +274,11 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -272,7 +291,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -289,16 +308,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -307,20 +329,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -341,13 +370,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -358,11 +390,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -410,22 +444,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -435,8 +474,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -458,7 +503,7 @@ async def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -476,13 +521,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_request( @@ -494,11 +542,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +577,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -545,13 +595,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -563,9 +616,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -577,9 +632,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index 69c73bc0f34a..bdb7b116a067 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -78,11 +80,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -132,17 +136,20 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -150,6 +157,8 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,13 +195,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -196,11 +214,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,21 +266,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -270,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -291,13 +322,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -307,11 +341,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,21 +394,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -382,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -401,17 +448,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -424,11 +474,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,9 +511,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -487,17 +539,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -505,20 +560,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -539,13 +601,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -556,11 +621,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -609,22 +676,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -634,8 +706,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -656,7 +734,7 @@ async def get( instance_id: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -674,13 +752,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -691,11 +772,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -723,7 +806,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -737,13 +820,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -753,11 +839,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -787,7 +875,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -811,13 +899,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -830,9 +921,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -845,9 +938,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -888,13 +983,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -905,11 +1003,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -961,22 +1061,27 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -986,8 +1091,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1007,13 +1118,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1023,11 +1137,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1072,21 +1188,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1096,8 +1217,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1117,13 +1244,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1133,11 +1263,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1182,21 +1314,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1206,8 +1343,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1227,13 +1370,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1243,11 +1389,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1293,21 +1441,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1317,8 +1470,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1339,7 +1498,7 @@ async def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -1358,13 +1517,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1375,11 +1537,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1407,13 +1571,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1423,11 +1590,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1472,21 +1641,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1496,8 +1670,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1531,13 +1711,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -1547,11 +1730,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1573,18 +1758,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1597,11 +1785,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1630,11 +1820,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1645,7 +1835,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1662,16 +1852,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1679,20 +1872,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_sets_operations.py index 67b9cca69f8b..31830bfc9a06 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -151,11 +160,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -185,9 +196,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -210,37 +221,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -257,17 +278,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -279,11 +303,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +335,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -334,37 +360,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -384,13 +420,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -400,11 +439,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,21 +491,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -474,8 +520,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -495,7 +547,7 @@ async def get( vm_scale_set_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -511,13 +563,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -527,11 +582,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -556,17 +613,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -581,11 +641,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -607,7 +669,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -634,23 +696,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -660,8 +727,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -678,18 +751,21 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -702,11 +778,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat json=_json, force_deletion=force_deletion, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -728,7 +806,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: @@ -756,17 +834,20 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, @@ -774,6 +855,8 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -783,8 +866,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -803,7 +892,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -815,13 +904,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -830,11 +922,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -860,7 +954,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -872,13 +966,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -887,9 +984,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -898,9 +997,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -937,7 +1038,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -949,13 +1050,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -963,9 +1067,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -973,9 +1079,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1014,7 +1122,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1029,13 +1137,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1045,9 +1156,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1057,9 +1170,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1098,7 +1213,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1112,13 +1227,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1128,9 +1246,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1140,9 +1260,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1180,17 +1302,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1206,11 +1331,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1233,7 +1360,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1264,17 +1391,20 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -1282,6 +1412,8 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1291,8 +1423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1309,17 +1447,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1334,11 +1475,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1360,7 +1503,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1385,23 +1528,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1411,8 +1559,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1429,17 +1583,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1454,11 +1611,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1480,7 +1639,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1505,23 +1664,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1531,8 +1695,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1549,17 +1719,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1574,11 +1747,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1600,7 +1775,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1626,23 +1801,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1652,8 +1832,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1670,17 +1856,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1695,11 +1884,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1721,7 +1912,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1749,23 +1940,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1775,8 +1971,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1793,17 +1995,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1815,11 +2020,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1841,7 +2048,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1865,23 +2072,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1891,8 +2103,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1909,17 +2127,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -1934,11 +2155,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1960,7 +2183,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -1986,23 +2209,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2012,8 +2240,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2030,17 +2264,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2055,11 +2292,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2081,7 +2320,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2107,23 +2346,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2133,8 +2377,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2154,7 +2404,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2170,13 +2420,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2186,11 +2439,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2216,7 +2471,7 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -2233,14 +2488,17 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret :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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -2252,11 +2510,13 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2277,17 +2537,20 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'OrchestrationServiceStateInput') @@ -2299,11 +2562,13 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2325,7 +2590,7 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> AsyncLROPoller[None]: """Changes ServiceState property for a given service. @@ -2348,23 +2613,28 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._set_orchestration_service_state_initial( + raw_result = await self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -2374,8 +2644,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_sizes_operations.py index ce51b1093671..16ec65a9e519 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machines_operations.py index a756a259979e..5aac2e93b5c1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -338,37 +364,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -385,17 +421,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -407,11 +446,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -437,9 +478,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -462,37 +503,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -512,13 +563,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -528,11 +582,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -578,21 +634,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -602,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -623,7 +690,7 @@ async def get( vm_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. @@ -641,13 +708,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -657,11 +727,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -688,7 +760,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -700,13 +772,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -715,11 +790,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -746,13 +823,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -761,11 +841,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -808,20 +890,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -831,8 +918,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -852,13 +945,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements hibernate: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -868,11 +964,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, hibernate=hibernate, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -919,21 +1017,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, hibernate=hibernate, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -943,8 +1046,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -980,13 +1089,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -995,11 +1107,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1021,7 +1135,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1034,13 +1148,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1049,9 +1166,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1060,9 +1179,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1100,7 +1221,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1114,13 +1235,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1129,9 +1253,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1140,9 +1266,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1181,7 +1309,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1196,13 +1324,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1212,9 +1343,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1224,9 +1357,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1266,13 +1401,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1282,11 +1420,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1334,21 +1474,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1358,8 +1503,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1378,13 +1529,16 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -1393,11 +1547,13 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1439,20 +1595,25 @@ async def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reapply_initial( + raw_result = await self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1462,8 +1623,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1482,13 +1649,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1497,11 +1667,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1543,20 +1715,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1566,8 +1743,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1586,13 +1769,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1601,11 +1787,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1647,20 +1835,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1670,8 +1863,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1690,13 +1889,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1705,11 +1907,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1751,20 +1955,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1774,8 +1983,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1792,17 +2007,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -1817,11 +2035,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1843,7 +2063,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -1867,23 +2087,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -1893,8 +2118,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1914,7 +2145,7 @@ async def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -1930,13 +2161,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1946,11 +2180,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1977,13 +2213,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1992,11 +2231,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2038,20 +2279,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2061,8 +2307,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2093,13 +2345,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2108,11 +2363,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2134,14 +2391,17 @@ async def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -2150,11 +2410,13 @@ async def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2183,7 +2445,7 @@ async def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -2204,34 +2466,44 @@ async def begin_assess_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = await self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -2248,17 +2520,20 @@ async def _install_patches_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineInstallPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineInstallPatchesResult"]] + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineInstallPatchesResult]] _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') @@ -2270,11 +2545,13 @@ async def _install_patches_initial( content_type=content_type, json=_json, template_url=self._install_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2302,9 +2579,9 @@ async def begin_install_patches( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineInstallPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. @@ -2328,37 +2605,47 @@ async def begin_install_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineInstallPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstallPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstallPatchesResult"] 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._install_patches_initial( + raw_result = await self._install_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineInstallPatchesResult', 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( @@ -2375,18 +2662,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2398,11 +2688,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2430,11 +2722,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2443,7 +2735,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2460,36 +2752,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/__init__.py index b70380135adb..9adb34daf549 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/__init__.py @@ -399,7 +399,9 @@ WindowsPatchAssessmentMode, WindowsVMGuestPatchMode, ) - +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__ = [ 'AdditionalCapabilities', 'AdditionalUnattendContent', @@ -791,3 +793,5 @@ 'WindowsPatchAssessmentMode', 'WindowsVMGuestPatchMode', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_compute_management_client_enums.py index 25c2f72f49ed..1b723b24ca25 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the aggregated replication status based on all the regional replication status flags. """ @@ -20,7 +19,7 @@ class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, En COMPLETED = "Completed" FAILED = "Failed" -class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. """ @@ -28,7 +27,7 @@ class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CLASSIC = "Classic" ALIGNED = "Aligned" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -39,15 +38,15 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class CapacityReservationGroupInstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CapacityReservationGroupInstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" -class CapacityReservationInstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CapacityReservationInstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" -class ConsistencyModeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConsistencyModeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the consistency mode for the restore point. Please refer to https://aka.ms/RestorePoints for more details. """ @@ -56,7 +55,7 @@ class ConsistencyModeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_SYSTEM_CONSISTENT = "FileSystemConsistent" APPLICATION_CONSISTENT = "ApplicationConsistent" -class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the software license type that will be applied to the VMs deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` @@ -67,20 +66,20 @@ class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" -class DeleteOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DeleteOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify what happens to the network interface when the VM is deleted """ DELETE = "Delete" DETACH = "Detach" -class DiffDiskOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk option for operating system disk. """ LOCAL = "Local" -class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskPlacement(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk placement for operating system disk. This property can be used by user in the request to choose the location i.e, cache disk or resource disk space for Ephemeral OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer @@ -93,7 +92,7 @@ class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CACHE_DISK = "CacheDisk" RESOURCE_DISK = "ResourceDisk" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -106,7 +105,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class DiskDeleteOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskDeleteOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the behavior of the managed disk when the VM gets deleted i.e whether the managed disk is deleted or detached. Supported values::code:`
`:code:`
` **Delete** If this value is used, the managed disk is deleted when VM gets deleted.:code:`
`:code:`
` **Detach** @@ -117,7 +116,7 @@ class DiskDeleteOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DELETE = "Delete" DETACH = "Detach" -class DiskDetachOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskDetachOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the detach behavior to be used while detaching a disk or which is already in the process of detachment from the virtual machine. Supported values: **ForceDetach**. :code:`
`:code:`
` detachOption: **ForceDetach** is applicable only for managed data @@ -131,7 +130,7 @@ class DiskDetachOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FORCE_DETACH = "ForceDetach" -class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExecutionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Script execution status. """ @@ -143,28 +142,28 @@ class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TIMED_OUT = "TimedOut" CANCELED = "Canceled" -class ExpandTypesForGetCapacityReservationGroups(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpandTypesForGetCapacityReservationGroups(str, Enum, metaclass=CaseInsensitiveEnumMeta): VIRTUAL_MACHINE_SCALE_SET_VMS_REF = "virtualMachineScaleSetVMs/$ref" VIRTUAL_MACHINES_REF = "virtualMachines/$ref" -class ExpandTypesForGetVMScaleSets(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpandTypesForGetVMScaleSets(str, Enum, metaclass=CaseInsensitiveEnumMeta): USER_DATA = "userData" -class ExtendedLocationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the extended location. """ EDGE_ZONE = "EdgeZone" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class GalleryApplicationVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryApplicationVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -175,7 +174,7 @@ class GalleryApplicationVersionPropertiesProvisioningState(with_metaclass(CaseIn DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImagePropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -186,7 +185,7 @@ class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnum DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImageVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -197,7 +196,7 @@ class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensit DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -208,7 +207,7 @@ class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, DELETING = "Deleting" MIGRATING = "Migrating" -class GallerySharingPermissionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GallerySharingPermissionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the permission of sharing gallery. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Private** :code:`
`:code:`
` **Groups** """ @@ -216,7 +215,7 @@ class GallerySharingPermissionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, PRIVATE = "Private" GROUPS = "Groups" -class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite' """ @@ -224,33 +223,33 @@ class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class HyperVGenerationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type associated with a resource """ V1 = "V1" V2 = "V2" -class HyperVGenerationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type """ V1 = "V1" V2 = "V2" -class InstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" USER_DATA = "userData" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -259,7 +258,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -268,7 +267,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class IPVersions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -277,7 +276,7 @@ class IPVersions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class LinuxPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinuxPatchAssessmentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` @@ -288,7 +287,7 @@ class LinuxPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class LinuxVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinuxVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's @@ -300,7 +299,7 @@ class LinuxVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -309,14 +308,14 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class NetworkApiVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations """ TWO_THOUSAND_TWENTY11_01 = "2020-11-01" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ @@ -325,34 +324,34 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: Specialized image. Contains already provisioned OS Disk. SPECIALIZED = "Specialized" -class OperatingSystemType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class OrchestrationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the orchestration mode for the virtual machine scale set. """ UNIFORM = "Uniform" FLEXIBLE = "Flexible" -class OrchestrationServiceNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the service. """ AUTOMATIC_REPAIRS = "AutomaticRepairs" -class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current state of the service. """ @@ -360,21 +359,21 @@ class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enu RUNNING = "Running" SUSPENDED = "Suspended" -class OrchestrationServiceStateAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceStateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The action to be performed. """ RESUME = "Resume" SUSPEND = "Suspend" -class PatchAssessmentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchAssessmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the availability of a given patch. """ UNKNOWN = "Unknown" AVAILABLE = "Available" -class PatchInstallationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchInstallationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the patch after the installation operation completed. """ @@ -385,7 +384,7 @@ class PatchInstallationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) NOT_SELECTED = "NotSelected" PENDING = "Pending" -class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", or "CompletedWithWarnings." @@ -397,7 +396,7 @@ class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -405,7 +404,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -414,28 +413,28 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class PublicIPAddressSkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAddressSkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify public IP sku name """ BASIC = "Basic" STANDARD = "Standard" -class PublicIPAddressSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAddressSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify public IP sku tier """ REGIONAL = "Regional" GLOBAL_ENUM = "Global" -class PublicIPAllocationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify the public IP allocation type """ DYNAMIC = "Dynamic" STATIC = "Static" -class ReplicationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Optional parameter which specifies the mode to be used for replication. This property is not updatable. """ @@ -443,7 +442,7 @@ class ReplicationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FULL = "Full" SHALLOW = "Shallow" -class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the regional replication state. """ @@ -452,11 +451,11 @@ class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAILED = "Failed" -class ReplicationStatusTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): REPLICATION_STATUS = "ReplicationStatus" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -467,7 +466,7 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuCapacityScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ @@ -475,32 +474,32 @@ class ResourceSkuCapacityScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, MANUAL = "Manual" NONE = "None" -class ResourceSkuRestrictionsReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuRestrictionsReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for restriction. """ QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class ResourceSkuRestrictionsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceSkuRestrictionsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of restrictions. """ LOCATION = "Location" ZONE = "Zone" -class RestorePointCollectionExpandOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RestorePointCollectionExpandOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): RESTORE_POINTS = "restorePoints" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -509,7 +508,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not be enabled unless this property is set as TrustedLaunch. @@ -517,11 +516,11 @@ class SecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TRUSTED_LAUNCH = "TrustedLaunch" -class SelectPermissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SelectPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): PERMISSIONS = "Permissions" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -529,11 +528,11 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class SharedToValues(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharedToValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): TENANT = "tenant" -class SharingProfileGroupTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharingProfileGroupTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the type of sharing group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Subscriptions** :code:`
`:code:`
` **AADTenants** @@ -542,7 +541,7 @@ class SharingProfileGroupTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum SUBSCRIPTIONS = "Subscriptions" AAD_TENANTS = "AADTenants" -class SharingUpdateOperationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharingUpdateOperationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the operation type of gallery sharing update. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset** @@ -552,7 +551,7 @@ class SharingUpdateOperationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E REMOVE = "Remove" RESET = "Reset" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -560,7 +559,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type to be used to store the image. This property is not updatable. """ @@ -569,7 +568,7 @@ class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can only be used with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. StandardSSD_LRS uses @@ -587,7 +586,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PREMIUM_ZRS = "Premium_ZRS" STANDARD_SSD_ZRS = "StandardSSD_ZRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -599,7 +598,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -607,7 +606,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -616,14 +615,14 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for the Azure Spot VM/VMSS """ DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for a standalone virtual machine or the virtual machines in the scale set. :code:`
`:code:`
` 'Low' enum will be deprecated in the future, please use 'Spot' as the enum to deploy Azure Spot VM/VMSS. @@ -633,20 +632,20 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E LOW = "Low" SPOT = "Spot" -class VirtualMachineScaleSetScaleInRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "Default" OLDEST_VM = "OldestVM" NEWEST_VM = "NewestVM" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. :code:`
`:code:`
` The enum data type is currently deprecated and will be removed by December 23rd 2023. :code:`
`:code:`
` Recommended way to get the list of available sizes is using these APIs: @@ -828,20 +827,20 @@ class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) STANDARD_NV12 = "Standard_NV12" STANDARD_NV24 = "Standard_NV24" -class VmDiskTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VmDiskTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """VM disk types which are disallowed. """ NONE = "None" UNMANAGED = "Unmanaged" -class VMGuestPatchClassificationLinux(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchClassificationLinux(str, Enum, metaclass=CaseInsensitiveEnumMeta): CRITICAL = "Critical" SECURITY = "Security" OTHER = "Other" -class VMGuestPatchClassificationWindows(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchClassificationWindows(str, Enum, metaclass=CaseInsensitiveEnumMeta): CRITICAL = "Critical" SECURITY = "Security" @@ -852,7 +851,7 @@ class VMGuestPatchClassificationWindows(with_metaclass(CaseInsensitiveEnumMeta, TOOLS = "Tools" UPDATES = "Updates" -class VMGuestPatchRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the reboot requirements of the patch. """ @@ -861,7 +860,7 @@ class VMGuestPatchRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, En ALWAYS_REQUIRES_REBOOT = "AlwaysRequiresReboot" CAN_REQUEST_REBOOT = "CanRequestReboot" -class VMGuestPatchRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines when it is acceptable to reboot a VM during a software update operation. """ @@ -869,7 +868,7 @@ class VMGuestPatchRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enu NEVER = "Never" ALWAYS = "Always" -class VMGuestPatchRebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reboot state of the VM following completion of the operation. """ @@ -880,7 +879,7 @@ class VMGuestPatchRebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" COMPLETED = "Completed" -class WindowsPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WindowsPatchAssessmentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest patch assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` @@ -891,7 +890,7 @@ class WindowsPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, En IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class WindowsVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WindowsVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_models_py3.py index ec8a94f34025..019488ebf90c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AdditionalCapabilities(msrest.serialization.Model): @@ -64,7 +66,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2021_07_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -85,7 +87,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -98,7 +100,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2021_07_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -166,8 +168,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -248,7 +250,7 @@ class ApplicationProfile(msrest.serialization.Model): def __init__( self, *, - gallery_applications: Optional[List["VMGalleryApplication"]] = None, + gallery_applications: Optional[List["_models.VMGalleryApplication"]] = None, **kwargs ): """ @@ -498,11 +500,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -560,7 +562,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -642,11 +644,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -682,8 +684,8 @@ class AvailablePatchSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_07_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -946,7 +948,7 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, **kwargs @@ -1116,7 +1118,7 @@ class CapacityReservationGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["CapacityReservationGroup"], + value: List["_models.CapacityReservationGroup"], next_link: Optional[str] = None, **kwargs ): @@ -1200,8 +1202,8 @@ class CapacityReservationInstanceView(msrest.serialization.Model): def __init__( self, *, - utilization_info: Optional["CapacityReservationUtilization"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + utilization_info: Optional["_models.CapacityReservationUtilization"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1243,8 +1245,8 @@ class CapacityReservationInstanceViewWithName(CapacityReservationInstanceView): def __init__( self, *, - utilization_info: Optional["CapacityReservationUtilization"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + utilization_info: Optional["_models.CapacityReservationUtilization"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1282,7 +1284,7 @@ class CapacityReservationListResult(msrest.serialization.Model): def __init__( self, *, - value: List["CapacityReservation"], + value: List["_models.CapacityReservation"], next_link: Optional[str] = None, **kwargs ): @@ -1315,7 +1317,7 @@ class CapacityReservationProfile(msrest.serialization.Model): def __init__( self, *, - capacity_reservation_group: Optional["SubResource"] = None, + capacity_reservation_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -1379,7 +1381,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -1531,11 +1533,11 @@ class CommunityGalleryImage(PirCommunityGalleryResource): :vartype unique_id: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes :ivar end_of_life_date: The end of life date of the gallery image definition. This property can @@ -1549,7 +1551,7 @@ class CommunityGalleryImage(PirCommunityGalleryResource): :ivar disallowed: Describes the disallowed disk types. :vartype disallowed: ~azure.mgmt.compute.v2021_07_01.models.Disallowed :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGeneration :ivar features: A list of gallery image features. :vartype features: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageFeature] @@ -1584,15 +1586,15 @@ def __init__( self, *, unique_id: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - features: Optional[List["GalleryImageFeature"]] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, **kwargs ): """ @@ -1600,12 +1602,12 @@ def __init__( :paramtype unique_id: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes :keyword end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -1618,7 +1620,7 @@ def __init__( :keyword disallowed: Describes the disallowed disk types. :paramtype disallowed: ~azure.mgmt.compute.v2021_07_01.models.Disallowed :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGeneration :keyword features: A list of gallery image features. :paramtype features: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageFeature] @@ -1798,8 +1800,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1810,7 +1811,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1837,14 +1838,14 @@ class DataDisk(msrest.serialization.Model): force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. :code:`
`:code:`
` This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data - disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Possible - values include: "ForceDetach". + disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Known values + are: "ForceDetach". :vartype detach_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskDetachOptionTypes :ivar delete_option: Specifies whether data disk should be deleted or detached upon VM deletion.:code:`
`:code:`
` Possible values: :code:`
`:code:`
` **Delete** If this value is used, the data disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the data disk is retained after VM is deleted.:code:`
`:code:`
` - The default value is set to **detach**. Possible values include: "Delete", "Detach". + The default value is set to **detach**. Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskDeleteOptionTypes """ @@ -1876,17 +1877,17 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, to_be_detached: Optional[bool] = None, - detach_option: Optional[Union[str, "DiskDetachOptionTypes"]] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + detach_option: Optional[Union[str, "_models.DiskDetachOptionTypes"]] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ @@ -1905,8 +1906,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1917,7 +1917,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1936,14 +1936,14 @@ def __init__( force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. :code:`
`:code:`
` This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data - disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Possible - values include: "ForceDetach". + disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Known values + are: "ForceDetach". :paramtype detach_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskDetachOptionTypes :keyword delete_option: Specifies whether data disk should be deleted or detached upon VM deletion.:code:`
`:code:`
` Possible values: :code:`
`:code:`
` **Delete** If this value is used, the data disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the data disk is retained after VM is deleted.:code:`
`:code:`
` - The default value is set to **detach**. Possible values include: "Delete", "Detach". + The default value is set to **detach**. Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskDeleteOptionTypes """ super(DataDisk, self).__init__(**kwargs) @@ -2095,7 +2095,7 @@ class DedicatedHost(Resource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -2140,11 +2140,11 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -2165,7 +2165,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostLicenseTypes """ @@ -2231,7 +2231,7 @@ class DedicatedHostAvailableCapacity(msrest.serialization.Model): def __init__( self, *, - allocatable_v_ms: Optional[List["DedicatedHostAllocatableVM"]] = None, + allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs ): """ @@ -2353,7 +2353,7 @@ class DedicatedHostGroupInstanceView(msrest.serialization.Model): def __init__( self, *, - hosts: Optional[List["DedicatedHostInstanceViewWithName"]] = None, + hosts: Optional[List["_models.DedicatedHostInstanceViewWithName"]] = None, **kwargs ): """ @@ -2389,7 +2389,7 @@ class DedicatedHostGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHostGroup"], + value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs ): @@ -2507,8 +2507,8 @@ class DedicatedHostInstanceView(msrest.serialization.Model): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2556,8 +2556,8 @@ class DedicatedHostInstanceViewWithName(DedicatedHostInstanceView): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2595,7 +2595,7 @@ class DedicatedHostListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHost"], + value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs ): @@ -2632,7 +2632,7 @@ class DedicatedHostUpdate(UpdateResource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -2669,7 +2669,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -2685,7 +2685,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostLicenseTypes """ @@ -2719,7 +2719,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -2738,8 +2738,8 @@ def __init__( class DiffDiskSettings(msrest.serialization.Model): """Describes the parameters of ephemeral disk settings that can be specified for operating system disk. :code:`
`:code:`
` NOTE: The ephemeral disk settings can only be specified for managed disk. - :ivar option: Specifies the ephemeral disk settings for operating system disk. Possible values - include: "Local". + :ivar option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :vartype option: str or ~azure.mgmt.compute.v2021_07_01.models.DiffDiskOptions :ivar placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -2748,7 +2748,7 @@ class DiffDiskSettings(msrest.serialization.Model): Refer to VM size documentation for Windows VM at https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Possible values include: "CacheDisk", "ResourceDisk". + cache disk. Known values are: "CacheDisk", "ResourceDisk". :vartype placement: str or ~azure.mgmt.compute.v2021_07_01.models.DiffDiskPlacement """ @@ -2760,13 +2760,13 @@ class DiffDiskSettings(msrest.serialization.Model): def __init__( self, *, - option: Optional[Union[str, "DiffDiskOptions"]] = None, - placement: Optional[Union[str, "DiffDiskPlacement"]] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, + placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, **kwargs ): """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. Possible - values include: "Local". + :keyword option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :paramtype option: str or ~azure.mgmt.compute.v2021_07_01.models.DiffDiskOptions :keyword placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -2775,7 +2775,7 @@ def __init__( Refer to VM size documentation for Windows VM at https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Possible values include: "CacheDisk", "ResourceDisk". + cache disk. Known values are: "CacheDisk", "ResourceDisk". :paramtype placement: str or ~azure.mgmt.compute.v2021_07_01.models.DiffDiskPlacement """ super(DiffDiskSettings, self).__init__(**kwargs) @@ -2811,8 +2811,7 @@ def __init__( class DisallowedConfiguration(msrest.serialization.Model): """Specifies the disallowed configuration for a virtual machine image. - :ivar vm_disk_type: VM disk types which are disallowed. Possible values include: "None", - "Unmanaged". + :ivar vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :vartype vm_disk_type: str or ~azure.mgmt.compute.v2021_07_01.models.VmDiskTypes """ @@ -2823,11 +2822,11 @@ class DisallowedConfiguration(msrest.serialization.Model): def __init__( self, *, - vm_disk_type: Optional[Union[str, "VmDiskTypes"]] = None, + vm_disk_type: Optional[Union[str, "_models.VmDiskTypes"]] = None, **kwargs ): """ - :keyword vm_disk_type: VM disk types which are disallowed. Possible values include: "None", + :keyword vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :paramtype vm_disk_type: str or ~azure.mgmt.compute.v2021_07_01.models.VmDiskTypes """ @@ -2905,8 +2904,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -2948,8 +2947,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2985,8 +2984,8 @@ class EncryptionImages(msrest.serialization.Model): def __init__( self, *, - os_disk_image: Optional["OSDiskImageEncryption"] = None, - data_disk_images: Optional[List["DataDiskImageEncryption"]] = None, + os_disk_image: Optional["_models.OSDiskImageEncryption"] = None, + data_disk_images: Optional[List["_models.DataDiskImageEncryption"]] = None, **kwargs ): """ @@ -3006,7 +3005,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.compute.v2021_07_01.models.ExtendedLocationTypes """ @@ -3019,13 +3018,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.compute.v2021_07_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -3055,8 +3054,8 @@ class Gallery(Resource): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2021_07_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_07_01.models.GalleryPropertiesProvisioningState :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. @@ -3092,9 +3091,9 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, - sharing_profile: Optional["SharingProfile"] = None, - soft_delete_policy: Optional["SoftDeletePolicy"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, + sharing_profile: Optional["_models.SharingProfile"] = None, + soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, **kwargs ): """ @@ -3152,8 +3151,8 @@ class GalleryApplication(Resource): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes """ @@ -3188,7 +3187,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -3210,8 +3209,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes """ @@ -3248,7 +3247,7 @@ class GalleryApplicationList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplication"], + value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs ): @@ -3337,8 +3336,8 @@ class GalleryApplicationUpdate(UpdateResourceDefinition): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes """ @@ -3370,7 +3369,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -3390,8 +3389,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes """ @@ -3424,8 +3423,8 @@ class GalleryApplicationVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionPropertiesProvisioningState :ivar replication_status: This is the replication status of the gallery image version. @@ -3457,7 +3456,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -3499,7 +3498,7 @@ class GalleryApplicationVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplicationVersion"], + value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs ): @@ -3536,11 +3535,11 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Possible values include: "Full", "Shallow". + This property is not updatable. Known values are: "Full", "Shallow". :vartype replication_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationMode """ @@ -3561,12 +3560,12 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "ReplicationMode"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, **kwargs ): """ @@ -3584,12 +3583,12 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Possible values include: "Full", "Shallow". + replication. This property is not updatable. Known values are: "Full", "Shallow". :paramtype replication_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationMode """ super(GalleryArtifactPublishingProfileBase, self).__init__(**kwargs) @@ -3625,11 +3624,11 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Possible values include: "Full", "Shallow". + This property is not updatable. Known values are: "Full", "Shallow". :vartype replication_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationMode :ivar source: Required. The source image from which the Image Version is going to be created. :vartype source: ~azure.mgmt.compute.v2021_07_01.models.UserArtifactSource @@ -3660,14 +3659,14 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil def __init__( self, *, - source: "UserArtifactSource", - target_regions: Optional[List["TargetRegion"]] = None, + source: "_models.UserArtifactSource", + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "ReplicationMode"]] = None, - manage_actions: Optional["UserArtifactManage"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + manage_actions: Optional["_models.UserArtifactManage"] = None, enable_health_check: Optional[bool] = None, **kwargs ): @@ -3686,12 +3685,12 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Possible values include: "Full", "Shallow". + replication. This property is not updatable. Known values are: "Full", "Shallow". :paramtype replication_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationMode :keyword source: Required. The source image from which the Image Version is going to be created. @@ -3723,8 +3722,8 @@ class GalleryApplicationVersionUpdate(UpdateResourceDefinition): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionPropertiesProvisioningState :ivar replication_status: This is the replication status of the gallery image version. @@ -3753,7 +3752,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -3789,7 +3788,7 @@ class GalleryArtifactSource(msrest.serialization.Model): def __init__( self, *, - managed_image: "ManagedArtifact", + managed_image: "_models.ManagedArtifact", **kwargs ): """ @@ -3844,7 +3843,7 @@ class GalleryDiskImage(msrest.serialization.Model): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2021_07_01.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource @@ -3863,13 +3862,13 @@ class GalleryDiskImage(msrest.serialization.Model): def __init__( self, *, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2021_07_01.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource @@ -3890,7 +3889,7 @@ class GalleryDataDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2021_07_01.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource @@ -3916,13 +3915,13 @@ def __init__( self, *, lun: int, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2021_07_01.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource @@ -3991,15 +3990,15 @@ class GalleryImage(Resource): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGeneration :ivar end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -4014,8 +4013,8 @@ class GalleryImage(Resource): :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2021_07_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_07_01.models.GalleryImagePropertiesProvisioningState :ivar features: A list of gallery image features. @@ -4061,15 +4060,15 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, - features: Optional[List["GalleryImageFeature"]] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, **kwargs ): """ @@ -4088,15 +4087,15 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGeneration :keyword end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -4234,7 +4233,7 @@ class GalleryImageList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImage"], + value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs ): @@ -4274,15 +4273,15 @@ class GalleryImageUpdate(UpdateResourceDefinition): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGeneration :ivar end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -4297,8 +4296,8 @@ class GalleryImageUpdate(UpdateResourceDefinition): :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2021_07_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_07_01.models.GalleryImagePropertiesProvisioningState :ivar features: A list of gallery image features. @@ -4341,15 +4340,15 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, - features: Optional[List["GalleryImageFeature"]] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, **kwargs ): """ @@ -4366,15 +4365,15 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGeneration :keyword end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -4429,8 +4428,8 @@ class GalleryImageVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionPropertiesProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -4466,8 +4465,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["GalleryImageVersionStorageProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -4513,7 +4512,7 @@ class GalleryImageVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImageVersion"], + value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs ): @@ -4550,11 +4549,11 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Possible values include: "Full", "Shallow". + This property is not updatable. Known values are: "Full", "Shallow". :vartype replication_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationMode """ @@ -4575,12 +4574,12 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "ReplicationMode"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, **kwargs ): """ @@ -4598,12 +4597,12 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Possible values include: "Full", "Shallow". + replication. This property is not updatable. Known values are: "Full", "Shallow". :paramtype replication_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationMode """ super(GalleryImageVersionPublishingProfile, self).__init__(target_regions=target_regions, replica_count=replica_count, exclude_from_latest=exclude_from_latest, end_of_life_date=end_of_life_date, storage_account_type=storage_account_type, replication_mode=replication_mode, **kwargs) @@ -4629,9 +4628,9 @@ class GalleryImageVersionStorageProfile(msrest.serialization.Model): def __init__( self, *, - source: Optional["GalleryArtifactVersionSource"] = None, - os_disk_image: Optional["GalleryOSDiskImage"] = None, - data_disk_images: Optional[List["GalleryDataDiskImage"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, + os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, + data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, **kwargs ): """ @@ -4664,8 +4663,8 @@ class GalleryImageVersionUpdate(UpdateResourceDefinition): :ivar publishing_profile: The publishing profile of a gallery image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionPropertiesProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -4698,8 +4697,8 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["GalleryImageVersionStorageProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -4743,7 +4742,7 @@ class GalleryList(msrest.serialization.Model): def __init__( self, *, - value: List["Gallery"], + value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs ): @@ -4767,7 +4766,7 @@ class GalleryOSDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2021_07_01.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource @@ -4786,13 +4785,13 @@ class GalleryOSDiskImage(GalleryDiskImage): def __init__( self, *, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2021_07_01.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2021_07_01.models.GalleryArtifactVersionSource @@ -4818,8 +4817,8 @@ class GalleryUpdate(UpdateResourceDefinition): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2021_07_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_07_01.models.GalleryPropertiesProvisioningState :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. @@ -4852,9 +4851,9 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, - sharing_profile: Optional["SharingProfile"] = None, - soft_delete_policy: Optional["SoftDeletePolicy"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, + sharing_profile: Optional["_models.SharingProfile"] = None, + soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, **kwargs ): """ @@ -4893,7 +4892,7 @@ class HardwareProfile(msrest.serialization.Model): `_. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The - available VM sizes depend on region and availability set. Possible values include: "Basic_A0", + available VM sizes depend on region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", @@ -4945,8 +4944,8 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, - vm_size_properties: Optional["VMSizeProperties"] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, + vm_size_properties: Optional["_models.VMSizeProperties"] = None, **kwargs ): """ @@ -4961,7 +4960,7 @@ def __init__( `_. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The - available VM sizes depend on region and availability set. Possible values include: "Basic_A0", + available VM sizes depend on region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", @@ -5037,8 +5036,8 @@ class Image(Resource): :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Possible - values include: "V1", "V2". + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationTypes """ @@ -5069,10 +5068,10 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -5090,7 +5089,7 @@ def __init__( from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the user to specify the property if we cannot deduce it from the source managed - resource. Possible values include: "V1", "V2". + resource. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationTypes """ @@ -5114,16 +5113,15 @@ class ImageDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes @@ -5146,13 +5144,13 @@ class ImageDisk(msrest.serialization.Model): def __init__( self, *, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -5165,16 +5163,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes @@ -5207,16 +5204,15 @@ class ImageDataDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes @@ -5249,13 +5245,13 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -5268,16 +5264,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes @@ -5318,7 +5313,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -5348,16 +5343,15 @@ class ImageOSDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes @@ -5367,10 +5361,10 @@ class ImageOSDisk(ImageDisk): ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSetParameters :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes """ @@ -5394,15 +5388,15 @@ class ImageOSDisk(ImageDisk): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -5415,16 +5409,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes @@ -5434,11 +5427,10 @@ def __init__( ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSetParameters :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes """ super(ImageOSDisk, self).__init__(snapshot=snapshot, managed_disk=managed_disk, blob_uri=blob_uri, caching=caching, disk_size_gb=disk_size_gb, storage_account_type=storage_account_type, disk_encryption_set=disk_encryption_set, **kwargs) @@ -5595,8 +5587,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -5637,8 +5629,8 @@ class ImageUpdate(UpdateResource): :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Possible - values include: "V1", "V2". + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationTypes """ @@ -5659,9 +5651,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -5675,7 +5667,7 @@ def __init__( from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the user to specify the property if we cannot deduce it from the source managed - resource. Possible values include: "V1", "V2". + resource. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationTypes """ @@ -5723,7 +5715,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2021_07_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -5745,7 +5737,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -5754,7 +5746,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2021_07_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -5796,7 +5788,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -5835,7 +5827,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -5856,8 +5848,8 @@ class LastPatchInstallationSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_07_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -5964,9 +5956,9 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, provision_vm_agent: Optional[bool] = None, - patch_settings: Optional["LinuxPatchSettings"] = None, + patch_settings: Optional["_models.LinuxPatchSettings"] = None, **kwargs ): """ @@ -6019,7 +6011,7 @@ class LinuxParameters(msrest.serialization.Model): def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "VMGuestPatchClassificationLinux"]]] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationLinux"]]] = None, package_name_masks_to_include: Optional[List[str]] = None, package_name_masks_to_exclude: Optional[List[str]] = None, maintenance_run_id: Optional[str] = None, @@ -6055,15 +6047,15 @@ class LinuxPatchSettings(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. Possible values include: "ImageDefault", + The property provisionVMAgent must be true. Known values are: "ImageDefault", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2021_07_01.models.LinuxVMGuestPatchMode :ivar assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :vartype assessment_mode: str or ~azure.mgmt.compute.v2021_07_01.models.LinuxPatchAssessmentMode """ @@ -6076,8 +6068,8 @@ class LinuxPatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "LinuxVMGuestPatchMode"]] = None, - assessment_mode: Optional[Union[str, "LinuxPatchAssessmentMode"]] = None, + patch_mode: Optional[Union[str, "_models.LinuxVMGuestPatchMode"]] = None, + assessment_mode: Optional[Union[str, "_models.LinuxPatchAssessmentMode"]] = None, **kwargs ): """ @@ -6086,15 +6078,15 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. Possible values include: "ImageDefault", + The property provisionVMAgent must be true. Known values are: "ImageDefault", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2021_07_01.models.LinuxVMGuestPatchMode :keyword assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :paramtype assessment_mode: str or ~azure.mgmt.compute.v2021_07_01.models.LinuxPatchAssessmentMode """ @@ -6127,7 +6119,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -6295,8 +6287,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2021_07_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -6321,7 +6313,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -6337,8 +6329,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2021_07_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -6391,8 +6383,8 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes @@ -6412,16 +6404,16 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes @@ -6444,7 +6436,7 @@ class NetworkInterfaceReference(SubResource): than 1 network interface. :vartype primary: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions """ @@ -6459,7 +6451,7 @@ def __init__( *, id: Optional[str] = None, primary: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -6469,7 +6461,7 @@ def __init__( than 1 network interface. :paramtype primary: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions """ super(NetworkInterfaceReference, self).__init__(id=id, **kwargs) @@ -6485,8 +6477,7 @@ class NetworkProfile(msrest.serialization.Model): :vartype network_interfaces: list[~azure.mgmt.compute.v2021_07_01.models.NetworkInterfaceReference] :ivar network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. Possible values include: - "2020-11-01". + networking resources in the Network Interface Configurations. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2021_07_01.models.NetworkApiVersion :ivar network_interface_configurations: Specifies the networking configurations that will be used to create the virtual machine networking resources. @@ -6503,9 +6494,9 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, - network_interface_configurations: Optional[List["VirtualMachineNetworkInterfaceConfiguration"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceConfiguration"]] = None, **kwargs ): """ @@ -6514,8 +6505,7 @@ def __init__( :paramtype network_interfaces: list[~azure.mgmt.compute.v2021_07_01.models.NetworkInterfaceReference] :keyword network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. Possible values include: - "2020-11-01". + networking resources in the Network Interface Configurations. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_07_01.models.NetworkApiVersion :keyword network_interface_configurations: Specifies the networking configurations that will be used to create the virtual machine networking resources. @@ -6533,11 +6523,9 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :ivar service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceNames - :ivar action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :ivar action: Required. The action to be performed. Known values are: "Resume", "Suspend". :vartype action: str or ~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceStateAction """ @@ -6554,17 +6542,15 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): def __init__( self, *, - service_name: Union[str, "OrchestrationServiceNames"], - action: Union[str, "OrchestrationServiceStateAction"], + service_name: Union[str, "_models.OrchestrationServiceNames"], + action: Union[str, "_models.OrchestrationServiceStateAction"], **kwargs ): """ - :keyword service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :keyword service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :paramtype service_name: str or ~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceNames - :keyword action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :keyword action: Required. The action to be performed. Known values are: "Resume", "Suspend". :paramtype action: str or ~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceStateAction """ @@ -6578,9 +6564,9 @@ class OrchestrationServiceSummary(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar service_name: The name of the service. Possible values include: "AutomaticRepairs". + :ivar service_name: The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceNames - :ivar service_state: The current state of the service. Possible values include: "NotRunning", + :ivar service_state: The current state of the service. Known values are: "NotRunning", "Running", "Suspended". :vartype service_state: str or ~azure.mgmt.compute.v2021_07_01.models.OrchestrationServiceState """ @@ -6613,8 +6599,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -6630,8 +6616,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -6645,7 +6630,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -6658,8 +6643,8 @@ class OSDisk(msrest.serialization.Model): used, the OS disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the os disk is retained after VM is deleted. :code:`
`:code:`
` The default value is set to **detach**. For an ephemeral OS Disk, the default value is set to - **Delete**. User cannot change the delete option for ephemeral OS Disk. Possible values - include: "Delete", "Detach". + **Delete**. User cannot change the delete option for ephemeral OS Disk. Known values are: + "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskDeleteOptionTypes """ @@ -6685,25 +6670,25 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -6719,8 +6704,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -6734,7 +6718,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -6747,8 +6731,8 @@ def __init__( value is used, the OS disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the os disk is retained after VM is deleted. :code:`
`:code:`
` The default value is set to **detach**. For an ephemeral OS Disk, the default value is set to - **Delete**. User cannot change the delete option for ephemeral OS Disk. Possible values - include: "Delete", "Detach". + **Delete**. User cannot change the delete option for ephemeral OS Disk. Known values are: + "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskDeleteOptionTypes """ super(OSDisk, self).__init__(**kwargs) @@ -6771,8 +6755,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes """ @@ -6787,12 +6771,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -6915,9 +6899,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, require_guest_provision_signal: Optional[bool] = None, **kwargs @@ -7020,8 +7004,7 @@ class PatchInstallationDetail(msrest.serialization.Model): :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] :ivar installation_state: The state of the patch after the installation operation completed. - Possible values include: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", - "Pending". + Known values are: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", "Pending". :vartype installation_state: str or ~azure.mgmt.compute.v2021_07_01.models.PatchInstallationState """ @@ -7071,8 +7054,8 @@ class PatchSettings(msrest.serialization.Model): **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2021_07_01.models.WindowsVMGuestPatchMode :ivar enable_hotpatching: Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must @@ -7082,8 +7065,8 @@ class PatchSettings(msrest.serialization.Model): machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :vartype assessment_mode: str or ~azure.mgmt.compute.v2021_07_01.models.WindowsPatchAssessmentMode """ @@ -7097,9 +7080,9 @@ class PatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "WindowsVMGuestPatchMode"]] = None, + patch_mode: Optional[Union[str, "_models.WindowsVMGuestPatchMode"]] = None, enable_hotpatching: Optional[bool] = None, - assessment_mode: Optional[Union[str, "WindowsPatchAssessmentMode"]] = None, + assessment_mode: Optional[Union[str, "_models.WindowsPatchAssessmentMode"]] = None, **kwargs ): """ @@ -7112,8 +7095,8 @@ def __init__( **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2021_07_01.models.WindowsVMGuestPatchMode :keyword enable_hotpatching: Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must @@ -7123,8 +7106,8 @@ def __init__( machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :paramtype assessment_mode: str or ~azure.mgmt.compute.v2021_07_01.models.WindowsPatchAssessmentMode """ @@ -7272,7 +7255,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -7319,8 +7302,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -7331,7 +7314,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroupType :keyword colocation_status: Describes colocation status of the Proximity Placement Group. @@ -7368,7 +7351,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -7447,9 +7430,9 @@ def __init__( class PublicIPAddressSku(msrest.serialization.Model): """Describes the public IP Sku. - :ivar name: Specify public IP sku name. Possible values include: "Basic", "Standard". + :ivar name: Specify public IP sku name. Known values are: "Basic", "Standard". :vartype name: str or ~azure.mgmt.compute.v2021_07_01.models.PublicIPAddressSkuName - :ivar tier: Specify public IP sku tier. Possible values include: "Regional", "Global". + :ivar tier: Specify public IP sku tier. Known values are: "Regional", "Global". :vartype tier: str or ~azure.mgmt.compute.v2021_07_01.models.PublicIPAddressSkuTier """ @@ -7461,14 +7444,14 @@ class PublicIPAddressSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "PublicIPAddressSkuName"]] = None, - tier: Optional[Union[str, "PublicIPAddressSkuTier"]] = None, + name: Optional[Union[str, "_models.PublicIPAddressSkuName"]] = None, + tier: Optional[Union[str, "_models.PublicIPAddressSkuTier"]] = None, **kwargs ): """ - :keyword name: Specify public IP sku name. Possible values include: "Basic", "Standard". + :keyword name: Specify public IP sku name. Known values are: "Basic", "Standard". :paramtype name: str or ~azure.mgmt.compute.v2021_07_01.models.PublicIPAddressSkuName - :keyword tier: Specify public IP sku tier. Possible values include: "Regional", "Global". + :keyword tier: Specify public IP sku tier. Known values are: "Regional", "Global". :paramtype tier: str or ~azure.mgmt.compute.v2021_07_01.models.PublicIPAddressSkuTier """ super(PublicIPAddressSku, self).__init__(**kwargs) @@ -7542,8 +7525,8 @@ class RecommendedMachineConfiguration(msrest.serialization.Model): def __init__( self, *, - v_cp_us: Optional["ResourceRange"] = None, - memory: Optional["ResourceRange"] = None, + v_cp_us: Optional["_models.ResourceRange"] = None, + memory: Optional["_models.ResourceRange"] = None, **kwargs ): """ @@ -7597,7 +7580,7 @@ class RegionalReplicationStatus(msrest.serialization.Model): :ivar region: The region to which the gallery image version is being replicated to. :vartype region: str - :ivar state: This is the regional replication state. Possible values include: "Unknown", + :ivar state: This is the regional replication state. Known values are: "Unknown", "Replicating", "Completed", "Failed". :vartype state: str or ~azure.mgmt.compute.v2021_07_01.models.ReplicationState :ivar details: The details of the replication status. @@ -7639,8 +7622,7 @@ class ReplicationStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Possible values include: "Unknown", "InProgress", "Completed", - "Failed". + replication status flags. Known values are: "Unknown", "InProgress", "Completed", "Failed". :vartype aggregated_state: str or ~azure.mgmt.compute.v2021_07_01.models.AggregatedReplicationState :ivar summary: This is a summary of replication status for each region. @@ -7691,7 +7673,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_user_agent: Group query result by User Agent. :vartype group_by_user_agent: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2021_07_01.models.IntervalInMins """ @@ -7720,7 +7702,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -7747,7 +7729,7 @@ def __init__( :keyword group_by_user_agent: Group query result by User Agent. :paramtype group_by_user_agent: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2021_07_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, group_by_client_application_id=group_by_client_application_id, group_by_user_agent=group_by_user_agent, **kwargs) @@ -7920,7 +7902,7 @@ class ResourceSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default: The default capacity. :vartype default: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "Manual", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceSkuCapacityScaleType """ @@ -8002,7 +7984,7 @@ class ResourceSkuLocationInfo(msrest.serialization.Model): :vartype zone_details: list[~azure.mgmt.compute.v2021_07_01.models.ResourceSkuZoneDetails] :ivar extended_locations: The names of extended locations. :vartype extended_locations: list[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.compute.v2021_07_01.models.ExtendedLocationType """ @@ -8073,14 +8055,14 @@ class ResourceSkuRestrictions(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: The type of restrictions. Possible values include: "Location", "Zone". + :ivar type: The type of restrictions. Known values are: "Location", "Zone". :vartype type: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceSkuRestrictionsType :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 restriction_info: The information about the restriction where the SKU cannot be used. :vartype restriction_info: ~azure.mgmt.compute.v2021_07_01.models.ResourceSkuRestrictionInfo - :ivar reason_code: The reason for restriction. Possible values include: "QuotaId", + :ivar reason_code: The reason for restriction. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceSkuRestrictionsReasonCode @@ -8137,7 +8119,7 @@ class ResourceSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["ResourceSku"], + value: List["_models.ResourceSku"], next_link: Optional[str] = None, **kwargs ): @@ -8206,7 +8188,7 @@ class RestorePoint(ProxyResource): :ivar provisioning_state: Gets the provisioning state of the restore point. :vartype provisioning_state: str :ivar consistency_mode: Gets the consistency mode for the restore point. Please refer to - https://aka.ms/RestorePoints for more details. Possible values include: "CrashConsistent", + https://aka.ms/RestorePoints for more details. Known values are: "CrashConsistent", "FileSystemConsistent", "ApplicationConsistent". :vartype consistency_mode: str or ~azure.mgmt.compute.v2021_07_01.models.ConsistencyModeTypes :ivar time_created: Gets the creation time of the restore point. @@ -8236,7 +8218,7 @@ class RestorePoint(ProxyResource): def __init__( self, *, - exclude_disks: Optional[List["ApiEntityReference"]] = None, + exclude_disks: Optional[List["_models.ApiEntityReference"]] = None, time_created: Optional[datetime.datetime] = None, **kwargs ): @@ -8311,7 +8293,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source: Optional["RestorePointCollectionSourceProperties"] = None, + source: Optional["_models.RestorePointCollectionSourceProperties"] = None, **kwargs ): """ @@ -8349,7 +8331,7 @@ class RestorePointCollectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RestorePointCollection"]] = None, + value: Optional[List["_models.RestorePointCollection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -8437,7 +8419,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["RestorePointCollectionSourceProperties"] = None, + source: Optional["_models.RestorePointCollectionSourceProperties"] = None, **kwargs ): """ @@ -8491,13 +8473,13 @@ class RestorePointSourceMetadata(msrest.serialization.Model): def __init__( self, *, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["RestorePointSourceVMStorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.RestorePointSourceVMStorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, license_type: Optional[str] = None, vm_id: Optional[str] = None, - security_profile: Optional["SecurityProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, location: Optional[str] = None, **kwargs ): @@ -8538,7 +8520,7 @@ class RestorePointSourceVMDataDisk(msrest.serialization.Model): :vartype lun: int :ivar name: Gets the disk name. :vartype name: str - :ivar caching: Gets the caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :ivar disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired size for existing OS and Data disks. @@ -8563,10 +8545,10 @@ def __init__( *, lun: Optional[int] = None, name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - disk_restore_point: Optional["ApiEntityReference"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + disk_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs ): """ @@ -8574,8 +8556,7 @@ def __init__( :paramtype lun: int :keyword name: Gets the disk name. :paramtype name: str - :keyword caching: Gets the caching type. Possible values include: "None", "ReadOnly", - "ReadWrite". + :keyword caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :keyword disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired size for existing OS and Data disks. @@ -8597,13 +8578,13 @@ def __init__( class RestorePointSourceVMOSDisk(msrest.serialization.Model): """Describes an Operating System disk. - :ivar os_type: Gets the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: Gets the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemType :ivar encryption_settings: Gets the disk encryption settings. :vartype encryption_settings: ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSettings :ivar name: Gets the disk name. :vartype name: str - :ivar caching: Gets the caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :ivar disk_size_gb: Gets the disk size in GB. :vartype disk_size_gb: int @@ -8626,24 +8607,23 @@ class RestorePointSourceVMOSDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Optional[Union[str, "OperatingSystemType"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemType"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - disk_restore_point: Optional["ApiEntityReference"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + disk_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs ): """ - :keyword os_type: Gets the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: Gets the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemType :keyword encryption_settings: Gets the disk encryption settings. :paramtype encryption_settings: ~azure.mgmt.compute.v2021_07_01.models.DiskEncryptionSettings :keyword name: Gets the disk name. :paramtype name: str - :keyword caching: Gets the caching type. Possible values include: "None", "ReadOnly", - "ReadWrite". + :keyword caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :keyword disk_size_gb: Gets the disk size in GB. :paramtype disk_size_gb: int @@ -8680,8 +8660,8 @@ class RestorePointSourceVMStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["RestorePointSourceVMOSDisk"] = None, - data_disks: Optional[List["RestorePointSourceVMDataDisk"]] = None, + os_disk: Optional["_models.RestorePointSourceVMOSDisk"] = None, + data_disks: Optional[List["_models.RestorePointSourceVMDataDisk"]] = None, **kwargs ): """ @@ -8912,13 +8892,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -9031,8 +9011,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -9061,7 +9040,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -9071,8 +9050,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -9096,8 +9074,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -9133,11 +9110,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -9145,8 +9122,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -9192,7 +9168,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -9273,7 +9249,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -9356,7 +9332,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -9400,7 +9376,7 @@ class ScaleInPolicy(msrest.serialization.Model): def __init__( self, *, - rules: Optional[List[Union[str, "VirtualMachineScaleSetScaleInRules"]]] = None, + rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, force_deletion: Optional[bool] = None, **kwargs ): @@ -9447,7 +9423,7 @@ class ScheduledEventsProfile(msrest.serialization.Model): def __init__( self, *, - terminate_notification_profile: Optional["TerminateNotificationProfile"] = None, + terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs ): """ @@ -9474,8 +9450,7 @@ class SecurityProfile(msrest.serialization.Model): :vartype encryption_at_host: bool :ivar security_type: Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not - be enabled unless this property is set as TrustedLaunch. Possible values include: - "TrustedLaunch". + be enabled unless this property is set as TrustedLaunch. Known values are: "TrustedLaunch". :vartype security_type: str or ~azure.mgmt.compute.v2021_07_01.models.SecurityTypes """ @@ -9488,9 +9463,9 @@ class SecurityProfile(msrest.serialization.Model): def __init__( self, *, - uefi_settings: Optional["UefiSettings"] = None, + uefi_settings: Optional["_models.UefiSettings"] = None, encryption_at_host: Optional[bool] = None, - security_type: Optional[Union[str, "SecurityTypes"]] = None, + security_type: Optional[Union[str, "_models.SecurityTypes"]] = None, **kwargs ): """ @@ -9505,8 +9480,7 @@ def __init__( :paramtype encryption_at_host: bool :keyword security_type: Specifies the SecurityType of the virtual machine. It is set as TrustedLaunch to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not - be enabled unless this property is set as TrustedLaunch. Possible values include: - "TrustedLaunch". + be enabled unless this property is set as TrustedLaunch. Known values are: "TrustedLaunch". :paramtype security_type: str or ~azure.mgmt.compute.v2021_07_01.models.SecurityTypes """ super(SecurityProfile, self).__init__(**kwargs) @@ -9565,11 +9539,11 @@ class SharedGalleryImage(PirSharedGalleryResource): :vartype unique_id: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes :ivar end_of_life_date: The end of life date of the gallery image definition. This property can @@ -9583,7 +9557,7 @@ class SharedGalleryImage(PirSharedGalleryResource): :ivar disallowed: Describes the disallowed disk types. :vartype disallowed: ~azure.mgmt.compute.v2021_07_01.models.Disallowed :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGeneration :ivar features: A list of gallery image features. :vartype features: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageFeature] @@ -9616,15 +9590,15 @@ def __init__( self, *, unique_id: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - features: Optional[List["GalleryImageFeature"]] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, **kwargs ): """ @@ -9632,12 +9606,12 @@ def __init__( :paramtype unique_id: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemStateTypes :keyword end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -9650,7 +9624,7 @@ def __init__( :keyword disallowed: Describes the disallowed disk types. :paramtype disallowed: ~azure.mgmt.compute.v2021_07_01.models.Disallowed :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGeneration :keyword features: A list of gallery image features. :paramtype features: list[~azure.mgmt.compute.v2021_07_01.models.GalleryImageFeature] @@ -9694,7 +9668,7 @@ class SharedGalleryImageList(msrest.serialization.Model): def __init__( self, *, - value: List["SharedGalleryImage"], + value: List["_models.SharedGalleryImage"], next_link: Optional[str] = None, **kwargs ): @@ -9789,7 +9763,7 @@ class SharedGalleryImageVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["SharedGalleryImageVersion"], + value: List["_models.SharedGalleryImageVersion"], next_link: Optional[str] = None, **kwargs ): @@ -9829,7 +9803,7 @@ class SharedGalleryList(msrest.serialization.Model): def __init__( self, *, - value: List["SharedGallery"], + value: List["_models.SharedGallery"], next_link: Optional[str] = None, **kwargs ): @@ -9852,7 +9826,7 @@ class SharingProfile(msrest.serialization.Model): :ivar permissions: This property allows you to specify the permission of sharing gallery. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Private** - :code:`
`:code:`
` **Groups**. Possible values include: "Private", "Groups". + :code:`
`:code:`
` **Groups**. Known values are: "Private", "Groups". :vartype permissions: str or ~azure.mgmt.compute.v2021_07_01.models.GallerySharingPermissionTypes :ivar groups: A list of sharing profile groups. @@ -9871,13 +9845,13 @@ class SharingProfile(msrest.serialization.Model): def __init__( self, *, - permissions: Optional[Union[str, "GallerySharingPermissionTypes"]] = None, + permissions: Optional[Union[str, "_models.GallerySharingPermissionTypes"]] = None, **kwargs ): """ :keyword permissions: This property allows you to specify the permission of sharing gallery. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Private** - :code:`
`:code:`
` **Groups**. Possible values include: "Private", "Groups". + :code:`
`:code:`
` **Groups**. Known values are: "Private", "Groups". :paramtype permissions: str or ~azure.mgmt.compute.v2021_07_01.models.GallerySharingPermissionTypes """ @@ -9891,8 +9865,7 @@ class SharingProfileGroup(msrest.serialization.Model): :ivar type: This property allows you to specify the type of sharing group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Subscriptions** - :code:`
`:code:`
` **AADTenants**. Possible values include: "Subscriptions", - "AADTenants". + :code:`
`:code:`
` **AADTenants**. Known values are: "Subscriptions", "AADTenants". :vartype type: str or ~azure.mgmt.compute.v2021_07_01.models.SharingProfileGroupTypes :ivar ids: A list of subscription/tenant ids the gallery is aimed to be shared to. :vartype ids: list[str] @@ -9906,15 +9879,14 @@ class SharingProfileGroup(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "SharingProfileGroupTypes"]] = None, + type: Optional[Union[str, "_models.SharingProfileGroupTypes"]] = None, ids: Optional[List[str]] = None, **kwargs ): """ :keyword type: This property allows you to specify the type of sharing group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Subscriptions** - :code:`
`:code:`
` **AADTenants**. Possible values include: "Subscriptions", - "AADTenants". + :code:`
`:code:`
` **AADTenants**. Known values are: "Subscriptions", "AADTenants". :paramtype type: str or ~azure.mgmt.compute.v2021_07_01.models.SharingProfileGroupTypes :keyword ids: A list of subscription/tenant ids the gallery is aimed to be shared to. :paramtype ids: list[str] @@ -9931,8 +9903,8 @@ class SharingUpdate(msrest.serialization.Model): :ivar operation_type: Required. This property allows you to specify the operation type of gallery sharing update. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` - **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Possible values - include: "Add", "Remove", "Reset". + **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Known values + are: "Add", "Remove", "Reset". :vartype operation_type: str or ~azure.mgmt.compute.v2021_07_01.models.SharingUpdateOperationTypes :ivar groups: A list of sharing profile groups. @@ -9951,15 +9923,15 @@ class SharingUpdate(msrest.serialization.Model): def __init__( self, *, - operation_type: Union[str, "SharingUpdateOperationTypes"], - groups: Optional[List["SharingProfileGroup"]] = None, + operation_type: Union[str, "_models.SharingUpdateOperationTypes"], + groups: Optional[List["_models.SharingProfileGroup"]] = None, **kwargs ): """ :keyword operation_type: Required. This property allows you to specify the operation type of gallery sharing update. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` - **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Possible values - include: "Add", "Remove", "Reset". + **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Known values + are: "Add", "Remove", "Reset". :paramtype operation_type: str or ~azure.mgmt.compute.v2021_07_01.models.SharingUpdateOperationTypes :keyword groups: A list of sharing profile groups. @@ -10091,7 +10063,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -10286,7 +10258,7 @@ class SshPublicKeysGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["SshPublicKeyResource"], + value: List["_models.SshPublicKeyResource"], next_link: Optional[str] = None, **kwargs ): @@ -10368,9 +10340,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -10442,7 +10414,7 @@ def __init__( self, *, id: Optional[str] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -10467,7 +10439,7 @@ class TargetRegion(msrest.serialization.Model): region. This property is updatable. :vartype regional_replica_count: int :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS @@ -10491,8 +10463,8 @@ def __init__( *, name: str, regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - encryption: Optional["EncryptionImages"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + encryption: Optional["_models.EncryptionImages"] = None, **kwargs ): """ @@ -10502,7 +10474,7 @@ def __init__( region. This property is updatable. :paramtype regional_replica_count: int :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountType @@ -10716,7 +10688,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2021_07_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2021_07_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -10763,7 +10735,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2021_07_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -10803,8 +10775,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2021_07_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -10824,9 +10796,9 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["AutomaticOSUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, + automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, **kwargs ): """ @@ -10834,8 +10806,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2021_07_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -10889,7 +10861,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -11147,8 +11119,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -11265,14 +11237,13 @@ class VirtualMachine(Resource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -11386,32 +11357,32 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, platform_fault_domain: Optional[int] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, - capacity_reservation: Optional["CapacityReservationProfile"] = None, - application_profile: Optional["ApplicationProfile"] = None, + capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, + application_profile: Optional["_models.ApplicationProfile"] = None, **kwargs ): """ @@ -11477,15 +11448,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -11592,8 +11562,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -11618,8 +11588,8 @@ class VirtualMachineAssessPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_07_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -11871,7 +11841,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, suppress_failures: Optional[bool] = None, **kwargs ): @@ -11946,7 +11916,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -12083,8 +12053,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -12121,7 +12091,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -12273,8 +12243,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -12298,15 +12268,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -12360,7 +12330,7 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, **kwargs ): """ @@ -12411,8 +12381,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2021_07_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: "V1", - "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationTypes :ivar disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -12449,14 +12418,14 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, - disallowed: Optional["DisallowedConfiguration"] = None, - features: Optional[List["VirtualMachineImageFeature"]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, + automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, + disallowed: Optional["_models.DisallowedConfiguration"] = None, + features: Optional[List["_models.VirtualMachineImageFeature"]] = None, **kwargs ): """ @@ -12483,8 +12452,7 @@ def __init__( image. :paramtype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2021_07_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: - "V1", "V2". + :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationTypes :keyword disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -12544,7 +12512,7 @@ class VirtualMachineInstallPatchesParameters(msrest.serialization.Model): must be an ISO 8601-compliant duration string such as PT4H (4 hours). :vartype maximum_duration: str :ivar reboot_setting: Required. Defines when it is acceptable to reboot a VM during a software - update operation. Possible values include: "IfRequired", "Never", "Always". + update operation. Known values are: "IfRequired", "Never", "Always". :vartype reboot_setting: str or ~azure.mgmt.compute.v2021_07_01.models.VMGuestPatchRebootSetting :ivar windows_parameters: Input for InstallPatches on a Windows VM, as directly received by the @@ -12569,10 +12537,10 @@ class VirtualMachineInstallPatchesParameters(msrest.serialization.Model): def __init__( self, *, - reboot_setting: Union[str, "VMGuestPatchRebootSetting"], + reboot_setting: Union[str, "_models.VMGuestPatchRebootSetting"], maximum_duration: Optional[str] = None, - windows_parameters: Optional["WindowsParameters"] = None, - linux_parameters: Optional["LinuxParameters"] = None, + windows_parameters: Optional["_models.WindowsParameters"] = None, + linux_parameters: Optional["_models.LinuxParameters"] = None, **kwargs ): """ @@ -12580,7 +12548,7 @@ def __init__( must be an ISO 8601-compliant duration string such as PT4H (4 hours). :paramtype maximum_duration: str :keyword reboot_setting: Required. Defines when it is acceptable to reboot a VM during a - software update operation. Possible values include: "IfRequired", "Never", "Always". + software update operation. Known values are: "IfRequired", "Never", "Always". :paramtype reboot_setting: str or ~azure.mgmt.compute.v2021_07_01.models.VMGuestPatchRebootSetting :keyword windows_parameters: Input for InstallPatches on a Windows VM, as directly received by @@ -12604,14 +12572,14 @@ class VirtualMachineInstallPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Failed", "Succeeded", "Unknown" or - "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_07_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. :vartype installation_activity_id: str - :ivar reboot_status: The reboot state of the VM following completion of the operation. Possible - values include: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". + :ivar reboot_status: The reboot state of the VM following completion of the operation. Known + values are: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". :vartype reboot_status: str or ~azure.mgmt.compute.v2021_07_01.models.VMGuestPatchRebootStatus :ivar maintenance_window_exceeded: Whether the operation ran out of time before it completed all its intended actions. @@ -12706,8 +12674,8 @@ class VirtualMachineInstanceView(msrest.serialization.Model): :vartype os_name: str :ivar os_version: The version of Operating System running on the virtual machine. :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationType :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. :vartype rdp_thumb_print: str @@ -12771,15 +12739,15 @@ def __init__( computer_name: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationType"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, - patch_status: Optional["VirtualMachinePatchStatus"] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, + patch_status: Optional["_models.VirtualMachinePatchStatus"] = None, **kwargs ): """ @@ -12794,7 +12762,7 @@ def __init__( :keyword os_version: The version of Operating System running on the virtual machine. :paramtype os_version: str :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_07_01.models.HyperVGenerationType :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. @@ -12894,7 +12862,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -12921,7 +12889,7 @@ class VirtualMachineNetworkInterfaceConfiguration(msrest.serialization.Model): than 1 network interface. :vartype primary: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated networking-enabled. @@ -12964,14 +12932,14 @@ def __init__( *, name: str, primary: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, enable_ip_forwarding: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineNetworkInterfaceDnsSettingsConfiguration"] = None, - ip_configurations: Optional[List["VirtualMachineNetworkInterfaceIPConfiguration"]] = None, - dscp_configuration: Optional["SubResource"] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineNetworkInterfaceDnsSettingsConfiguration"] = None, + ip_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceIPConfiguration"]] = None, + dscp_configuration: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -12981,7 +12949,7 @@ def __init__( than 1 network interface. :paramtype primary: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated networking-enabled. @@ -13056,7 +13024,7 @@ class VirtualMachineNetworkInterfaceIPConfiguration(msrest.serialization.Model): ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersions :ivar application_security_groups: Specifies an array of references to application security group. @@ -13094,13 +13062,13 @@ def __init__( self, *, name: str, - subnet: Optional["SubResource"] = None, + subnet: Optional["_models.SubResource"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachinePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersions"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachinePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersions"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -13116,7 +13084,7 @@ def __init__( ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersions :keyword application_security_groups: Specifies an array of references to application security group. @@ -13176,8 +13144,8 @@ class VirtualMachinePatchStatus(msrest.serialization.Model): def __init__( self, *, - available_patch_summary: Optional["AvailablePatchSummary"] = None, - last_patch_installation_summary: Optional["LastPatchInstallationSummary"] = None, + available_patch_summary: Optional["_models.AvailablePatchSummary"] = None, + last_patch_installation_summary: Optional["_models.LastPatchInstallationSummary"] = None, **kwargs ): """ @@ -13208,7 +13176,7 @@ class VirtualMachinePublicIPAddressConfiguration(msrest.serialization.Model): :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. :vartype idle_timeout_in_minutes: int :ivar delete_option: Specify what happens to the public IP address when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions :ivar dns_settings: The dns settings to be applied on the publicIP addresses . :vartype dns_settings: @@ -13219,10 +13187,10 @@ class VirtualMachinePublicIPAddressConfiguration(msrest.serialization.Model): :vartype public_ip_prefix: ~azure.mgmt.compute.v2021_07_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersions - :ivar public_ip_allocation_method: Specify the public IP allocation type. Possible values - include: "Dynamic", "Static". + :ivar public_ip_allocation_method: Specify the public IP allocation type. Known values are: + "Dynamic", "Static". :vartype public_ip_allocation_method: str or ~azure.mgmt.compute.v2021_07_01.models.PublicIPAllocationMethod """ @@ -13247,14 +13215,14 @@ def __init__( self, *, name: str, - sku: Optional["PublicIPAddressSku"] = None, + sku: Optional["_models.PublicIPAddressSku"] = None, idle_timeout_in_minutes: Optional[int] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, - dns_settings: Optional["VirtualMachinePublicIPAddressDnsSettingsConfiguration"] = None, - ip_tags: Optional[List["VirtualMachineIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersions"]] = None, - public_ip_allocation_method: Optional[Union[str, "PublicIPAllocationMethod"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachinePublicIPAddressDnsSettingsConfiguration"] = None, + ip_tags: Optional[List["_models.VirtualMachineIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersions"]] = None, + public_ip_allocation_method: Optional[Union[str, "_models.PublicIPAllocationMethod"]] = None, **kwargs ): """ @@ -13265,7 +13233,7 @@ def __init__( :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. :paramtype idle_timeout_in_minutes: int :keyword delete_option: Specify what happens to the public IP address when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions :keyword dns_settings: The dns settings to be applied on the publicIP addresses . :paramtype dns_settings: @@ -13276,10 +13244,10 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2021_07_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersions - :keyword public_ip_allocation_method: Specify the public IP allocation type. Possible values - include: "Dynamic", "Static". + :keyword public_ip_allocation_method: Specify the public IP allocation type. Known values are: + "Dynamic", "Static". :paramtype public_ip_allocation_method: str or ~azure.mgmt.compute.v2021_07_01.models.PublicIPAllocationMethod """ @@ -13437,9 +13405,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -13494,7 +13462,7 @@ def __init__( class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): """The instance view of a virtual machine run command. - :ivar execution_state: Script execution status. Possible values include: "Unknown", "Pending", + :ivar execution_state: Script execution status. Known values are: "Unknown", "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :vartype execution_state: str or ~azure.mgmt.compute.v2021_07_01.models.ExecutionState :ivar execution_message: Communicate script configuration errors or execution messages. @@ -13527,19 +13495,19 @@ class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): def __init__( self, *, - execution_state: Optional[Union[str, "ExecutionState"]] = None, + execution_state: Optional[Union[str, "_models.ExecutionState"]] = None, execution_message: Optional[str] = None, exit_code: Optional[int] = None, output: Optional[str] = None, error: Optional[str] = None, start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ - :keyword execution_state: Script execution status. Possible values include: "Unknown", - "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". + :keyword execution_state: Script execution status. Known values are: "Unknown", "Pending", + "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :paramtype execution_state: str or ~azure.mgmt.compute.v2021_07_01.models.ExecutionState :keyword execution_message: Communicate script configuration errors or execution messages. :paramtype execution_message: str @@ -13629,7 +13597,7 @@ class VirtualMachineRunCommandsListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineRunCommand"], + value: List["_models.VirtualMachineRunCommand"], next_link: Optional[str] = None, **kwargs ): @@ -13705,9 +13673,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -13834,7 +13802,7 @@ class VirtualMachineScaleSet(Resource): Virtual Machine Scale Set. :vartype scale_in_policy: ~azure.mgmt.compute.v2021_07_01.models.ScaleInPolicy :ivar orchestration_mode: Specifies the orchestration mode for the virtual machine scale set. - Possible values include: "Uniform", "Flexible". + Known values are: "Uniform", "Flexible". :vartype orchestration_mode: str or ~azure.mgmt.compute.v2021_07_01.models.OrchestrationMode :ivar spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale set. @@ -13884,25 +13852,25 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - orchestration_mode: Optional[Union[str, "OrchestrationMode"]] = None, - spot_restore_policy: Optional["SpotRestorePolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + orchestration_mode: Optional[Union[str, "_models.OrchestrationMode"]] = None, + spot_restore_policy: Optional["_models.SpotRestorePolicy"] = None, **kwargs ): """ @@ -13968,7 +13936,7 @@ def __init__( the Virtual Machine Scale Set. :paramtype scale_in_policy: ~azure.mgmt.compute.v2021_07_01.models.ScaleInPolicy :keyword orchestration_mode: Specifies the orchestration mode for the virtual machine scale - set. Possible values include: "Uniform", "Flexible". + set. Known values are: "Uniform", "Flexible". :paramtype orchestration_mode: str or ~azure.mgmt.compute.v2021_07_01.models.OrchestrationMode :keyword spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale set. @@ -14012,14 +13980,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -14059,12 +14026,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -14079,14 +14046,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -14272,7 +14238,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -14309,7 +14275,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, extensions_time_budget: Optional[str] = None, **kwargs ): @@ -14472,7 +14438,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine @@ -14497,15 +14463,15 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2021_07_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual @@ -14588,7 +14554,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -14649,7 +14615,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -14693,14 +14659,14 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -14718,7 +14684,7 @@ def __init__( ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -14810,7 +14776,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -14851,7 +14817,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -14891,7 +14857,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -14931,7 +14897,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -14951,8 +14917,8 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): """Describes the parameters of a ScaleSet managed disk. :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes @@ -14970,14 +14936,14 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_07_01.models.StorageAccountTypes @@ -15019,7 +14985,7 @@ class VirtualMachineScaleSetNetworkConfiguration(SubResource): :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions """ @@ -15048,11 +15014,11 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -15079,7 +15045,7 @@ def __init__( :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions """ super(VirtualMachineScaleSetNetworkConfiguration, self).__init__(id=id, **kwargs) @@ -15131,7 +15097,7 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetNetworkConfiguration] :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2021_07_01.models.NetworkApiVersion """ @@ -15144,9 +15110,9 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, **kwargs ): """ @@ -15159,7 +15125,7 @@ def __init__( list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetNetworkConfiguration] :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_07_01.models.NetworkApiVersion """ super(VirtualMachineScaleSetNetworkProfile, self).__init__(**kwargs) @@ -15178,8 +15144,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -15188,8 +15153,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -15200,8 +15165,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk @@ -15233,16 +15198,16 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -15251,8 +15216,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -15261,8 +15225,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_07_01.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -15274,7 +15238,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_07_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2021_07_01.models.VirtualHardDisk @@ -15368,9 +15332,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -15454,10 +15418,10 @@ class VirtualMachineScaleSetPublicIPAddressConfiguration(msrest.serialization.Mo :vartype public_ip_prefix: ~azure.mgmt.compute.v2021_07_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersion - :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values + are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions """ @@ -15480,13 +15444,13 @@ def __init__( self, *, name: str, - sku: Optional["PublicIPAddressSku"] = None, + sku: Optional["_models.PublicIPAddressSku"] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -15505,10 +15469,10 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2021_07_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersion - :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known + values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions """ super(VirtualMachineScaleSetPublicIPAddressConfiguration, self).__init__(**kwargs) @@ -15668,8 +15632,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -15731,9 +15694,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -15824,18 +15787,18 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - proximity_placement_group: Optional["SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -15913,7 +15876,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -15947,14 +15910,14 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -15972,7 +15935,7 @@ def __init__( ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_07_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -16026,7 +15989,7 @@ class VirtualMachineScaleSetUpdateNetworkConfiguration(SubResource): :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions """ @@ -16051,11 +16014,11 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -16081,7 +16044,7 @@ def __init__( :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions """ super(VirtualMachineScaleSetUpdateNetworkConfiguration, self).__init__(id=id, **kwargs) @@ -16108,7 +16071,7 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2021_07_01.models.NetworkApiVersion """ @@ -16121,9 +16084,9 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, **kwargs ): """ @@ -16136,7 +16099,7 @@ def __init__( list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_07_01.models.NetworkApiVersion """ super(VirtualMachineScaleSetUpdateNetworkProfile, self).__init__(**kwargs) @@ -16148,7 +16111,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -16180,16 +16143,16 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_07_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -16241,9 +16204,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -16273,8 +16236,8 @@ class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration(msrest.serializat :ivar dns_settings: The dns settings to be applied on the publicIP addresses . :vartype dns_settings: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values + are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions """ @@ -16290,8 +16253,8 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -16302,8 +16265,8 @@ def __init__( :keyword dns_settings: The dns settings to be applied on the publicIP addresses . :paramtype dns_settings: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings - :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known + values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_07_01.models.DeleteOptions """ super(VirtualMachineScaleSetUpdatePublicIPAddressConfiguration, self).__init__(**kwargs) @@ -16334,9 +16297,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -16402,15 +16365,15 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, **kwargs ): @@ -16603,18 +16566,18 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - network_profile_configuration: Optional["VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, - protection_policy: Optional["VirtualMachineScaleSetVMProtectionPolicy"] = None, + protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, user_data: Optional[str] = None, **kwargs ): @@ -16785,7 +16748,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, suppress_failures: Optional[bool] = None, **kwargs ): @@ -16850,7 +16813,7 @@ class VirtualMachineScaleSetVMExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineScaleSetVMExtension"]] = None, + value: Optional[List["_models.VirtualMachineScaleSetVMExtension"]] = None, **kwargs ): """ @@ -17137,12 +17100,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -17213,7 +17176,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -17244,7 +17207,7 @@ class VirtualMachineScaleSetVMNetworkProfileConfiguration(msrest.serialization.M def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -17291,15 +17254,14 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -17341,20 +17303,20 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, - capacity_reservation: Optional["CapacityReservationProfile"] = None, - application_profile: Optional["ApplicationProfile"] = None, + capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, + application_profile: Optional["_models.ApplicationProfile"] = None, **kwargs ): """ @@ -17390,15 +17352,14 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -17560,7 +17521,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -17586,7 +17547,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype kb_id: str :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] - :ivar reboot_behavior: Describes the reboot requirements of the patch. Possible values include: + :ivar reboot_behavior: Describes the reboot requirements of the patch. Known values are: "Unknown", "NeverReboots", "AlwaysRequiresReboot", "CanRequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.compute.v2021_07_01.models.VMGuestPatchRebootBehavior @@ -17597,7 +17558,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype published_date: ~datetime.datetime :ivar last_modified_date_time: The UTC timestamp of the last update to this patch record. :vartype last_modified_date_time: ~datetime.datetime - :ivar assessment_state: Describes the availability of a given patch. Possible values include: + :ivar assessment_state: Describes the availability of a given patch. Known values are: "Unknown", "Available". :vartype assessment_state: str or ~azure.mgmt.compute.v2021_07_01.models.PatchAssessmentState """ @@ -17741,14 +17702,13 @@ class VirtualMachineUpdate(UpdateResource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -17850,31 +17810,31 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, platform_fault_domain: Optional[int] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, - capacity_reservation: Optional["CapacityReservationProfile"] = None, - application_profile: Optional["ApplicationProfile"] = None, + capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, + application_profile: Optional["_models.ApplicationProfile"] = None, **kwargs ): """ @@ -17936,15 +17896,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_07_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -18212,9 +18171,9 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - patch_settings: Optional["PatchSettings"] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + patch_settings: Optional["_models.PatchSettings"] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -18283,7 +18242,7 @@ class WindowsParameters(msrest.serialization.Model): def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "VMGuestPatchClassificationWindows"]]] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationWindows"]]] = None, kb_numbers_to_include: Optional[List[str]] = None, kb_numbers_to_exclude: Optional[List[str]] = None, exclude_kbs_requiring_reboot: Optional[bool] = None, @@ -18328,7 +18287,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -18343,7 +18302,7 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :vartype protocol: str or ~azure.mgmt.compute.v2021_07_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as @@ -18368,13 +18327,13 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2021_07_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/__init__.py index cca9cf86cf8d..6265718bd8a6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/__init__.py @@ -46,6 +46,9 @@ from ._community_gallery_images_operations import CommunityGalleryImagesOperations from ._community_gallery_image_versions_operations import CommunityGalleryImageVersionsOperations +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', 'AvailabilitySetsOperations', @@ -87,3 +90,5 @@ 'CommunityGalleryImagesOperations', 'CommunityGalleryImageVersionsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_availability_sets_operations.py index ad4ffa956aa8..d943082f15de 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -151,9 +153,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -165,18 +170,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -187,9 +190,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -199,20 +205,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -235,18 +242,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -257,9 +262,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -271,51 +279,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -329,14 +333,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -348,11 +355,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -378,9 +387,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -394,14 +403,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -413,11 +425,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,13 +470,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -471,11 +488,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -498,7 +517,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -510,13 +529,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -525,11 +547,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -555,7 +579,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -568,13 +592,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -583,9 +610,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -594,9 +623,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -634,7 +665,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -646,13 +677,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +695,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -672,9 +708,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -713,7 +751,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -728,13 +766,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -756,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_capacity_reservation_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_capacity_reservation_groups_operations.py index dce8153fd383..c9e06f7e345b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_capacity_reservation_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_capacity_reservation_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( capacity_reservation_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservationGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( capacity_reservation_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservationGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,9 +123,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_get_request( expand: Optional[Union[str, "_models.CapacityReservationGroupInstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,20 +179,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_by_resource_group_request( expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -211,20 +218,18 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -235,9 +240,12 @@ def build_list_by_subscription_request( expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/capacityReservationGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -247,53 +255,49 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) -class CapacityReservationGroupsOperations(object): - """CapacityReservationGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CapacityReservationGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroup", + parameters: _models.CapacityReservationGroup, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details. @@ -309,14 +313,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroup') @@ -328,11 +335,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -362,9 +371,9 @@ def update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroupUpdate", + parameters: _models.CapacityReservationGroupUpdate, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. @@ -379,14 +388,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroupUpdate') @@ -398,11 +410,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -444,13 +458,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -459,11 +476,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -487,7 +506,7 @@ def get( capacity_reservation_group_name: str, expand: Optional[Union[str, "_models.CapacityReservationGroupInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation that retrieves information about a capacity reservation group. :param resource_group_name: The name of the resource group. @@ -505,13 +524,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] request = build_get_request( @@ -521,11 +543,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -552,7 +576,7 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> Iterable["_models.CapacityReservationGroupListResult"]: + ) -> Iterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -570,13 +594,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -586,9 +613,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, 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: @@ -598,9 +627,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -638,7 +669,7 @@ def list_by_subscription( self, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> Iterable["_models.CapacityReservationGroupListResult"]: + ) -> Iterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -654,13 +685,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -669,9 +703,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -680,9 +716,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_capacity_reservations_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_capacity_reservations_operations.py index 36d82ea65552..f644e4fdaf27 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_capacity_reservations_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_capacity_reservations_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( capacity_reservation_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservation] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( capacity_reservation_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservationUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -168,9 +171,12 @@ def build_get_request( expand: Optional[Union[str, "_models.CapacityReservationInstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -183,20 +189,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -207,9 +211,12 @@ def build_list_by_capacity_reservation_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations") # pylint: disable=line-too-long path_format_arguments = { @@ -221,59 +228,58 @@ def build_list_by_capacity_reservation_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CapacityReservationsOperations(object): - """CapacityReservationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CapacityReservationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`capacity_reservations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> "_models.CapacityReservation": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] + ) -> _models.CapacityReservation: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] _json = self._serialize.body(parameters, 'CapacityReservation') @@ -286,11 +292,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -321,9 +329,9 @@ def begin_create_or_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> LROPoller["_models.CapacityReservation"]: + ) -> LROPoller[_models.CapacityReservation]: """The operation to create or update a capacity reservation. Please note some properties can be set only during capacity reservation creation. Please refer to https://aka.ms/CapacityReservation for more details. @@ -350,17 +358,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -368,20 +379,27 @@ def begin_create_or_update( 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('CapacityReservation', 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( @@ -399,17 +417,20 @@ def _update_initial( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> Optional["_models.CapacityReservation"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CapacityReservation"]] + ) -> Optional[_models.CapacityReservation]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.CapacityReservation]] _json = self._serialize.body(parameters, 'CapacityReservationUpdate') @@ -422,11 +443,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -455,9 +478,9 @@ def begin_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> LROPoller["_models.CapacityReservation"]: + ) -> LROPoller[_models.CapacityReservation]: """The operation to update a capacity reservation. :param resource_group_name: The name of the resource group. @@ -482,17 +505,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -500,20 +526,27 @@ def begin_update( 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('CapacityReservation', 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( @@ -533,13 +566,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements capacity_reservation_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -549,11 +585,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -600,21 +638,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -624,8 +667,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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,7 +695,7 @@ def get( capacity_reservation_name: str, expand: Optional[Union[str, "_models.CapacityReservationInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservation": + ) -> _models.CapacityReservation: """The operation that retrieves information about the capacity reservation. :param resource_group_name: The name of the resource group. @@ -665,13 +714,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CapacityReservation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] request = build_get_request( @@ -682,11 +734,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -713,7 +767,7 @@ def list_by_capacity_reservation_group( resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> Iterable["_models.CapacityReservationListResult"]: + ) -> Iterable[_models.CapacityReservationListResult]: """Lists all of the capacity reservations in the specified capacity reservation group. Use the nextLink property in the response to get the next page of capacity reservations. @@ -728,13 +782,16 @@ def list_by_capacity_reservation_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.CapacityReservationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +801,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_capacity_reservation_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: @@ -756,9 +815,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_community_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_community_galleries_operations.py index 06b2dd5d9f99..51cbb082f014 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_community_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_community_galleries_operations.py @@ -15,6 +15,7 @@ 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 @@ -31,9 +32,12 @@ def build_get_request( public_gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -45,42 +49,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CommunityGalleriesOperations(object): - """CommunityGalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CommunityGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`community_galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -88,7 +88,7 @@ def get( location: str, public_gallery_name: str, **kwargs: Any - ) -> "_models.CommunityGallery": + ) -> _models.CommunityGallery: """Get a community gallery by gallery public name. :param location: Resource location. @@ -100,13 +100,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CommunityGallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGallery] request = build_get_request( @@ -115,11 +118,13 @@ def get( public_gallery_name=public_gallery_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_community_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_community_gallery_image_versions_operations.py index f7a404a348e6..3f11e7fd967a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_community_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_community_gallery_image_versions_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,42 +53,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CommunityGalleryImageVersionsOperations(object): - """CommunityGalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CommunityGalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`community_gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -94,7 +94,7 @@ def get( gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any - ) -> "_models.CommunityGalleryImageVersion": + ) -> _models.CommunityGalleryImageVersion: """Get a community gallery image version. :param location: Resource location. @@ -113,13 +113,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CommunityGalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGalleryImageVersion] request = build_get_request( @@ -130,11 +133,13 @@ def get( gallery_image_version_name=gallery_image_version_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_community_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_community_gallery_images_operations.py index b03a59a64fea..a216b39ccecc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_community_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_community_gallery_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -32,9 +33,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -47,42 +51,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CommunityGalleryImagesOperations(object): - """CommunityGalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CommunityGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`community_gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -91,7 +91,7 @@ def get( public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.CommunityGalleryImage": + ) -> _models.CommunityGalleryImage: """Get a community gallery image. :param location: Resource location. @@ -105,13 +105,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.CommunityGalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGalleryImage] request = build_get_request( @@ -121,11 +124,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_dedicated_host_groups_operations.py index 3c4b5cda87a1..d9aac982ce17 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_dedicated_host_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +172,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -190,9 +193,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -203,18 +209,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -223,9 +227,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") path_format_arguments = { @@ -235,51 +242,47 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostGroupsOperations(object): - """DedicatedHostGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -295,14 +298,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -314,11 +320,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -348,9 +356,9 @@ def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -364,14 +372,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -383,11 +394,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -426,13 +439,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -441,11 +457,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -469,7 +487,7 @@ def get( host_group_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -485,13 +503,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -501,11 +522,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -531,7 +554,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -544,13 +567,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -559,9 +585,11 @@ def prepare_request(next_link=None): 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: @@ -570,9 +598,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -609,7 +639,7 @@ def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -620,13 +650,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -634,9 +667,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -644,9 +679,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_dedicated_hosts_operations.py index f14fd5584084..76e84cce0a7a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHost] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_by_host_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_by_host_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostsOperations(object): - """DedicatedHostsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -341,17 +348,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -359,20 +369,27 @@ def begin_create_or_update( 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('DedicatedHost', 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( @@ -390,17 +407,20 @@ def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -413,11 +433,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -444,9 +466,9 @@ def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -470,17 +492,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -488,20 +513,27 @@ def begin_update( 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('DedicatedHost', 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( @@ -521,13 +553,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements host_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -537,11 +572,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -586,21 +623,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -610,8 +652,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -632,7 +680,7 @@ def get( host_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -650,13 +698,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -667,11 +718,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -698,7 +751,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostListResult"]: + ) -> Iterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -713,13 +766,16 @@ def list_by_host_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -729,9 +785,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -741,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_galleries_operations.py index 3aa087fa2c61..e6f45dd6fa3a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.Gallery] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -125,9 +127,12 @@ def build_get_request( select: Optional[Union[str, "_models.SelectPermissions"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -139,20 +144,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -163,9 +166,12 @@ def build_delete_request_initial( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,18 +183,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries") # pylint: disable=line-too-long path_format_arguments = { @@ -211,18 +218,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +236,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") path_format_arguments = { @@ -243,58 +251,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleriesOperations(object): - """GalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -306,11 +313,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -343,9 +352,9 @@ def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -367,37 +376,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -414,17 +433,20 @@ def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'GalleryUpdate') @@ -436,11 +458,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -466,9 +490,9 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -490,37 +514,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -540,7 +574,7 @@ def get( gallery_name: str, select: Optional[Union[str, "_models.SelectPermissions"]] = None, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -554,13 +588,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -570,11 +607,13 @@ def get( api_version=api_version, select=select, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -601,13 +640,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -616,11 +658,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -662,20 +706,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +734,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -704,7 +759,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -714,13 +769,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -729,9 +787,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -740,9 +800,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -779,7 +841,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -787,13 +849,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -801,9 +866,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -811,9 +878,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_application_versions_operations.py index 1fe2b9b8da5e..7f18e3f7d3c5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +137,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +156,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -177,9 +180,12 @@ def build_delete_request_initial( gallery_application_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +199,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -216,9 +220,12 @@ def build_list_by_gallery_application_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -231,42 +238,38 @@ def build_list_by_gallery_application_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationVersionsOperations(object): - """GalleryApplicationVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -274,17 +277,20 @@ def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -298,11 +304,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -373,17 +381,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -392,20 +403,27 @@ def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -424,17 +442,20 @@ def _update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersionUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,9 +503,9 @@ def begin_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -516,17 +539,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -535,20 +561,27 @@ def begin_update( 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('GalleryApplicationVersion', 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( @@ -570,7 +603,7 @@ def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -591,13 +624,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -609,11 +645,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -642,13 +680,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -659,11 +700,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -714,22 +757,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -739,8 +787,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -760,7 +814,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationVersionList"]: + ) -> Iterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -778,13 +832,16 @@ def list_by_gallery_application( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +852,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -808,9 +867,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_applications_operations.py index 971cff7faf6d..7f16215e4fcf 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplication] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_get_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -181,18 +187,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +207,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications") # pylint: disable=line-too-long path_format_arguments = { @@ -217,59 +224,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationsOperations(object): - """GalleryApplicationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -282,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -320,9 +328,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -351,17 +359,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -369,20 +380,27 @@ def begin_create_or_update( 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('GalleryApplication', 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( @@ -400,17 +418,20 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplicationUpdate') @@ -423,11 +444,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -454,9 +477,9 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -484,17 +507,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -502,20 +528,27 @@ def begin_update( 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('GalleryApplication', 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( @@ -535,7 +568,7 @@ def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -551,13 +584,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -567,11 +603,13 @@ def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -599,13 +637,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -615,11 +656,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -665,21 +708,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -689,8 +737,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -709,7 +763,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationList"]: + ) -> Iterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -724,13 +778,16 @@ def list_by_gallery( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -740,9 +797,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -752,9 +811,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_image_versions_operations.py index 200ca7d17539..e6055ca07014 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +137,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +156,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -177,9 +180,12 @@ def build_delete_request_initial( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +199,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -216,9 +220,12 @@ def build_list_by_gallery_image_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -231,42 +238,38 @@ def build_list_by_gallery_image_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImageVersionsOperations(object): - """GalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -274,17 +277,20 @@ def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -298,11 +304,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Create or update a gallery image version. :param resource_group_name: The name of the resource group. @@ -372,17 +380,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -423,17 +441,20 @@ def _update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersionUpdate') @@ -447,11 +468,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -479,9 +502,9 @@ def begin_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Update a gallery image version. :param resource_group_name: The name of the resource group. @@ -514,17 +537,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -533,20 +559,27 @@ def begin_update( 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('GalleryImageVersion', 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( @@ -568,7 +601,7 @@ def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery image version. :param resource_group_name: The name of the resource group. @@ -588,13 +621,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -606,11 +642,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -639,13 +677,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -656,11 +697,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -710,22 +753,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -735,8 +783,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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,7 +810,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageVersionList"]: + ) -> Iterable[_models.GalleryImageVersionList]: """List gallery image versions in a gallery image definition. :param resource_group_name: The name of the resource group. @@ -774,13 +828,16 @@ def list_by_gallery_image( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -791,9 +848,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -804,9 +863,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_images_operations.py index 0103c3ae8bf4..1c6135c33e05 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImage] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -181,18 +187,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +207,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images") # pylint: disable=line-too-long path_format_arguments = { @@ -217,59 +224,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImagesOperations(object): - """GalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -282,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -320,9 +328,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Create or update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -349,17 +357,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -367,20 +378,27 @@ def begin_create_or_update( 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('GalleryImage', 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( @@ -398,17 +416,20 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImageUpdate') @@ -421,11 +442,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +475,9 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -481,17 +504,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -499,20 +525,27 @@ def begin_update( 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('GalleryImage', 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( @@ -532,7 +565,7 @@ def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery image definition. :param resource_group_name: The name of the resource group. @@ -547,13 +580,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -563,11 +599,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,13 +633,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -611,11 +652,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -661,21 +704,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +733,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +759,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageList"]: + ) -> Iterable[_models.GalleryImageList]: """List gallery image definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -718,13 +772,16 @@ def list_by_gallery( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -734,9 +791,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -746,9 +805,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_sharing_profile_operations.py index 8e1f35339773..1b26afe27617 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_sharing_profile_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_gallery_sharing_profile_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +33,17 @@ def build_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.SharingUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share") # pylint: disable=line-too-long path_format_arguments = { @@ -52,62 +55,61 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class GallerySharingProfileOperations(object): - """GallerySharingProfileOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GallerySharingProfileOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`gallery_sharing_profile` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _update_initial( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> "_models.SharingUpdate": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] + ) -> _models.SharingUpdate: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharingUpdate] _json = self._serialize.body(sharing_update, 'SharingUpdate') @@ -119,11 +121,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -153,9 +157,9 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> LROPoller["_models.SharingUpdate"]: + ) -> LROPoller[_models.SharingUpdate]: """Update sharing profile of a gallery. :param resource_group_name: The name of the resource group. @@ -177,37 +181,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.SharingUpdate] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharingUpdate] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, sharing_update=sharing_update, 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('SharingUpdate', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_images_operations.py index 636b6e2f52da..c20e7f4d533f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,8 +125,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,13 +139,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -155,9 +157,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -169,20 +174,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -192,9 +195,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -205,18 +211,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,9 +229,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -237,58 +244,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -300,11 +306,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -334,9 +342,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -357,37 +365,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -404,17 +422,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -426,11 +447,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -460,9 +483,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -483,37 +506,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -532,13 +565,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -547,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -593,20 +631,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -616,8 +659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -637,7 +686,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -651,13 +700,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -667,11 +719,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -697,7 +751,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -707,13 +761,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -722,9 +779,11 @@ def prepare_request(next_link=None): 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: @@ -733,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -772,7 +833,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -781,13 +842,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +859,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -805,9 +871,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_log_analytics_operations.py index 06bd0d0a46fe..69611516d572 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_operations.py index 036fd0efac81..7a600ff24eb2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_proximity_placement_groups_operations.py index 23bdc4d7fd8d..d60c11ebf127 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,8 +123,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,13 +137,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -153,9 +155,12 @@ def build_get_request( include_colocation_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -167,20 +172,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if include_colocation_status is not None: - _query_parameters['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -189,9 +192,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -222,9 +226,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -235,51 +242,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -293,14 +296,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -312,11 +318,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -346,9 +354,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -362,14 +370,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -381,11 +392,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -424,13 +437,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -439,11 +455,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -467,7 +485,7 @@ def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -482,13 +500,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -498,11 +519,13 @@ def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +550,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -537,13 +560,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -551,9 +577,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -561,9 +589,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -601,7 +631,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -613,13 +643,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -628,9 +661,11 @@ def prepare_request(next_link=None): 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: @@ -639,9 +674,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_resource_skus_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_resource_skus_operations.py index 79c71638f68b..772f2bd8e63f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_resource_skus_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_resource_skus_operations.py @@ -16,6 +16,7 @@ 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 @@ -33,9 +34,12 @@ def build_list_request( include_extended_locations: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/skus") path_format_arguments = { @@ -45,46 +49,42 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if include_extended_locations is not None: - _query_parameters['includeExtendedLocations'] = _SERIALIZER.query("include_extended_locations", include_extended_locations, 'str') + _params['includeExtendedLocations'] = _SERIALIZER.query("include_extended_locations", include_extended_locations, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ResourceSkusOperations(object): - """ResourceSkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourceSkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`resource_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( @@ -92,7 +92,7 @@ def list( filter: Optional[str] = None, include_extended_locations: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ResourceSkusResult"]: + ) -> Iterable[_models.ResourceSkusResult]: """Gets the list of Microsoft.Compute SKUs available for your Subscription. :param filter: The filter to apply on the operation. Only **location** filter is supported @@ -106,13 +106,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ResourceSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -122,9 +125,11 @@ def prepare_request(next_link=None): filter=filter, include_extended_locations=include_extended_locations, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -134,9 +139,11 @@ def prepare_request(next_link=None): filter=filter, include_extended_locations=include_extended_locations, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_restore_point_collections_operations.py index 3a47768cfa16..955812ae2a0e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_restore_point_collections_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_restore_point_collections_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request( resource_group_name: str, restore_point_collection_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePointCollection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request( resource_group_name: str, restore_point_collection_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePointCollectionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( restore_point_collection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -161,9 +164,12 @@ def build_get_request( expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections") # pylint: disable=line-too-long path_format_arguments = { @@ -211,18 +218,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +236,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/restorePointCollections") path_format_arguments = { @@ -243,51 +251,47 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class RestorePointCollectionsOperations(object): - """RestorePointCollectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RestorePointCollectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollection", + parameters: _models.RestorePointCollection, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. @@ -304,14 +308,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollection') @@ -323,11 +330,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -357,9 +366,9 @@ def update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollectionUpdate", + parameters: _models.RestorePointCollectionUpdate, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. @@ -373,14 +382,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollectionUpdate') @@ -392,11 +404,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -423,13 +437,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -438,11 +455,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_name=restore_point_collection_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -485,20 +504,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -508,8 +532,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -529,7 +559,7 @@ def get( restore_point_collection_name: str, expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to get the restore point collection. :param resource_group_name: The name of the resource group. @@ -544,13 +574,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] request = build_get_request( @@ -560,11 +593,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -590,7 +625,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.RestorePointCollectionListResult"]: + ) -> Iterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in a resource group. :param resource_group_name: The name of the resource group. @@ -602,13 +637,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -617,9 +655,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -628,9 +668,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -667,7 +709,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.RestorePointCollectionListResult"]: + ) -> Iterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in the subscription. Use nextLink property in the response to get the next page of restore point collections. Do this till nextLink is not null to fetch all the restore point collections. @@ -679,13 +721,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -693,9 +738,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -703,9 +750,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_restore_points_operations.py index 570b45ac1d1f..b4bfe28a4522 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_restore_points_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_restore_points_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_request_initial( restore_point_collection_name: str, restore_point_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePoint] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,9 +82,12 @@ def build_delete_request_initial( restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -96,18 +100,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -119,9 +121,12 @@ def build_get_request( restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -134,59 +139,58 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class RestorePointsOperations(object): - """RestorePointsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`restore_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_initial( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> "_models.RestorePoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] + ) -> _models.RestorePoint: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] _json = self._serialize.body(parameters, 'RestorePoint') @@ -199,11 +203,13 @@ def _create_initial( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -230,9 +236,9 @@ def begin_create( resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> LROPoller["_models.RestorePoint"]: + ) -> LROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. @@ -257,17 +263,20 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RestorePoint] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] 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, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, @@ -275,20 +284,27 @@ def begin_create( 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('RestorePoint', 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( @@ -308,13 +324,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -324,11 +343,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_name=restore_point_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -373,21 +394,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -397,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -418,7 +450,7 @@ def get( restore_point_collection_name: str, restore_point_name: str, **kwargs: Any - ) -> "_models.RestorePoint": + ) -> _models.RestorePoint: """The operation to get the restore point. :param resource_group_name: The name of the resource group. @@ -432,13 +464,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] request = build_get_request( @@ -448,11 +483,13 @@ def get( restore_point_name=restore_point_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_shared_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_shared_galleries_operations.py index 269fa40a66f0..98301113defa 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_shared_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_shared_galleries_operations.py @@ -16,6 +16,7 @@ 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 @@ -33,9 +34,12 @@ def build_list_request( shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries") # pylint: disable=line-too-long path_format_arguments = { @@ -46,20 +50,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 shared_to is not None: - _query_parameters['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') + _params['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -70,9 +72,12 @@ def build_get_request( gallery_unique_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}") # pylint: disable=line-too-long path_format_arguments = { @@ -84,42 +89,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class SharedGalleriesOperations(object): - """SharedGalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharedGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`shared_galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -127,7 +128,7 @@ def list( location: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> Iterable["_models.SharedGalleryList"]: + ) -> Iterable[_models.SharedGalleryList]: """List shared galleries by subscription id or tenant id. :param location: Resource location. @@ -140,13 +141,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.SharedGalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -156,9 +160,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -168,9 +174,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -209,7 +217,7 @@ def get( location: str, gallery_unique_name: str, **kwargs: Any - ) -> "_models.SharedGallery": + ) -> _models.SharedGallery: """Get a shared gallery by subscription id or tenant id. :param location: Resource location. @@ -221,13 +229,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SharedGallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGallery] request = build_get_request( @@ -236,11 +247,13 @@ def get( gallery_unique_name=gallery_unique_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_shared_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_shared_gallery_image_versions_operations.py index 3ea64f2f3ee7..971906ef1b6c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_shared_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_shared_gallery_image_versions_operations.py @@ -16,6 +16,7 @@ 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 @@ -35,9 +36,12 @@ def build_list_request( shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +54,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 shared_to is not None: - _query_parameters['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') + _params['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -76,9 +78,12 @@ def build_get_request( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -92,42 +97,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class SharedGalleryImageVersionsOperations(object): - """SharedGalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharedGalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`shared_gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -137,7 +138,7 @@ def list( gallery_image_name: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> Iterable["_models.SharedGalleryImageVersionList"]: + ) -> Iterable[_models.SharedGalleryImageVersionList]: """List shared gallery image versions by subscription id or tenant id. :param location: Resource location. @@ -157,13 +158,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -175,9 +179,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -189,9 +195,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -232,7 +240,7 @@ def get( gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any - ) -> "_models.SharedGalleryImageVersion": + ) -> _models.SharedGalleryImageVersion: """Get a shared gallery image version by subscription id or tenant id. :param location: Resource location. @@ -252,13 +260,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageVersion] request = build_get_request( @@ -269,11 +280,13 @@ def get( gallery_image_version_name=gallery_image_version_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_shared_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_shared_gallery_images_operations.py index 91abeef7335f..b6e88a18f816 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_shared_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_shared_gallery_images_operations.py @@ -16,6 +16,7 @@ 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 @@ -34,9 +35,12 @@ def build_list_request( shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images") # pylint: disable=line-too-long path_format_arguments = { @@ -48,20 +52,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 shared_to is not None: - _query_parameters['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') + _params['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -73,9 +75,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -88,42 +93,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class SharedGalleryImagesOperations(object): - """SharedGalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharedGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`shared_gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -132,7 +133,7 @@ def list( gallery_unique_name: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> Iterable["_models.SharedGalleryImageList"]: + ) -> Iterable[_models.SharedGalleryImageList]: """List shared gallery images by subscription id or tenant id. :param location: Resource location. @@ -149,13 +150,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -166,9 +170,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -179,9 +185,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -221,7 +229,7 @@ def get( gallery_unique_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.SharedGalleryImage": + ) -> _models.SharedGalleryImage: """Get a shared gallery image by subscription id or tenant id. :param location: Resource location. @@ -236,13 +244,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SharedGalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImage] request = build_get_request( @@ -252,11 +263,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_ssh_public_keys_operations.py index e877ffee7f62..e2bf317bfd34 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_ssh_public_keys_operations.py @@ -16,12 +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 .. 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,9 +31,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") path_format_arguments = { @@ -43,18 +46,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -64,9 +65,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys") # pylint: disable=line-too-long path_format_arguments = { @@ -77,18 +81,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -98,14 +100,17 @@ def build_create_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -117,20 +122,18 @@ def build_create_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -142,14 +145,17 @@ def build_update_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyUpdateResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -161,20 +167,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -187,8 +191,9 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -200,13 +205,12 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -217,9 +221,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -231,18 +238,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -253,9 +258,12 @@ def build_generate_key_pair_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair") # pylint: disable=line-too-long path_format_arguments = { @@ -267,48 +275,44 @@ def build_generate_key_pair_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class SshPublicKeysOperations(object): - """SshPublicKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -319,13 +323,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -333,9 +340,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -343,9 +352,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -383,7 +394,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -396,13 +407,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -411,9 +425,11 @@ def prepare_request(next_link=None): 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: @@ -422,9 +438,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -462,9 +480,9 @@ def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -478,14 +496,17 @@ def create( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -497,11 +518,13 @@ def create( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -531,9 +554,9 @@ def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -547,14 +570,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -566,11 +592,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -609,13 +637,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -624,11 +655,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -651,7 +684,7 @@ def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -663,13 +696,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -678,11 +714,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -709,7 +747,7 @@ def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -723,13 +761,16 @@ def generate_key_pair( :rtype: ~azure.mgmt.compute.v2021_07_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -738,11 +779,13 @@ def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_usage_operations.py index 2b8b192f17c0..09bbb01c9895 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_extension_images_operations.py index 620102d802bb..ebc2375dfa87 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_extensions_operations.py index 067540d860bf..5d39c3f09a77 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,8 +129,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -141,13 +144,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -161,9 +163,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -176,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -202,9 +205,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -216,61 +222,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -283,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -318,9 +325,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -347,17 +354,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -365,20 +375,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -396,17 +413,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -419,11 +439,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,9 +472,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -479,17 +501,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -497,20 +522,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -530,13 +562,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -546,11 +581,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,21 +632,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -619,8 +661,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -641,7 +689,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -657,13 +705,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -674,11 +725,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -706,7 +759,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -720,13 +773,16 @@ def list( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -736,11 +792,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_images_edge_zone_operations.py index 6af9783177c0..581cda0fc984 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_images_edge_zone_operations.py @@ -15,6 +15,7 @@ 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 @@ -35,9 +36,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,18 +57,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -82,9 +84,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -99,24 +104,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -128,9 +131,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +149,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -165,9 +169,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -179,18 +186,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +208,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -219,42 +227,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesEdgeZoneOperations(object): - """VirtualMachineImagesEdgeZoneOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesEdgeZoneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -266,7 +270,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. @@ -286,13 +290,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -305,11 +312,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -342,7 +351,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. @@ -369,13 +378,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -390,11 +402,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -422,7 +436,7 @@ def list_offers( edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. @@ -437,13 +451,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -453,11 +470,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -484,7 +503,7 @@ def list_publishers( location: str, edge_zone: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. @@ -496,13 +515,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -511,11 +533,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -544,7 +568,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. @@ -561,13 +585,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -578,11 +605,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_images_operations.py index fc2030fe5a47..85a7ec48d82b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_run_commands_operations.py index 329cb6878519..d00f0dd19942 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -69,9 +70,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -83,18 +87,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -105,14 +107,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -125,20 +130,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -151,14 +154,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,20 +177,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -198,9 +202,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -213,18 +220,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -238,9 +243,12 @@ def build_get_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -253,20 +261,18 @@ def build_get_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -279,9 +285,12 @@ def build_list_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -293,51 +302,47 @@ def build_list_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -349,13 +354,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +372,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -375,9 +385,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -416,7 +428,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -428,13 +440,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -443,11 +458,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -473,18 +490,21 @@ def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -497,11 +517,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,11 +554,11 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -548,7 +570,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -565,16 +587,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -582,20 +607,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -613,18 +645,21 @@ def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -637,11 +672,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -668,11 +705,11 @@ def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -683,7 +720,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -700,16 +737,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -717,20 +757,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -750,13 +797,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -766,11 +816,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,21 +867,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -839,8 +896,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -861,7 +924,7 @@ def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -877,13 +940,16 @@ def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -894,11 +960,13 @@ def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -926,7 +994,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -942,13 +1010,16 @@ def list_by_virtual_machine( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -959,9 +1030,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -972,9 +1045,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_extensions_operations.py index 73b6518464fb..afeb361c573c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,8 +130,9 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,13 +145,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -162,9 +164,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +182,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +204,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -215,59 +221,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -280,11 +285,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -315,9 +322,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -345,17 +352,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -363,20 +373,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -394,17 +411,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -417,11 +437,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +474,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -481,17 +503,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -499,20 +524,27 @@ def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -532,13 +564,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -548,11 +583,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -597,21 +634,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -621,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -643,7 +691,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -659,13 +707,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -676,11 +727,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -707,7 +760,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -721,13 +774,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -737,9 +793,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -749,9 +807,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 790d848466bb..5b6dffd18f9e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,8 +34,9 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -46,13 +48,12 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -63,8 +64,9 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -76,13 +78,12 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -93,8 +94,9 @@ def build_start_extension_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -106,13 +108,12 @@ def build_start_extension_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -123,9 +124,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -137,42 +141,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -180,13 +180,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -195,11 +198,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -241,20 +246,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -264,8 +274,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -284,13 +300,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -299,11 +318,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -347,20 +368,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -370,8 +396,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -390,13 +422,16 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -405,11 +440,13 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -453,20 +490,25 @@ def begin_start_extension_upgrade( # pylint: disable=inconsistent-return-statem :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_extension_upgrade_initial( + raw_result = self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -476,8 +518,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -496,7 +544,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -508,13 +556,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -523,11 +574,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py index cf9575d49762..fe879ff00072 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -56,20 +59,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -83,14 +84,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -104,20 +108,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -132,9 +134,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -148,18 +153,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -174,9 +177,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -190,20 +196,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -217,9 +221,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -232,44 +239,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMExtensionsOperations(object): - """VirtualMachineScaleSetVMExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -277,17 +280,20 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -301,11 +307,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -368,17 +376,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -387,20 +398,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -419,17 +437,20 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -443,11 +464,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -475,9 +498,9 @@ def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -506,17 +529,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -525,20 +551,27 @@ def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -559,13 +592,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -576,11 +612,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -628,22 +666,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -653,8 +696,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -676,7 +725,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -694,13 +743,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -712,11 +764,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -745,7 +799,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -761,13 +815,16 @@ def list( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -778,11 +835,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index ec02c9228a94..be581c731904 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -133,9 +135,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -149,18 +154,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -175,9 +178,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -191,20 +197,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -218,9 +222,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -233,44 +240,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMRunCommandsOperations(object): - """VirtualMachineScaleSetVMRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -278,18 +281,21 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -303,11 +309,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -339,11 +347,11 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -356,7 +364,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -373,16 +381,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -423,18 +441,21 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,11 +503,11 @@ def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -497,7 +520,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -514,16 +537,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -532,20 +558,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -566,13 +599,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -583,11 +619,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,22 +673,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -660,8 +703,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -683,7 +732,7 @@ def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -701,13 +750,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_request( @@ -719,11 +771,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -752,7 +806,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -770,13 +824,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -788,9 +845,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -802,9 +861,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_vms_operations.py index a80f560dc584..338e517879a0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,13 +35,15 @@ def build_reimage_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -54,19 +56,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,8 +80,9 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -94,13 +95,12 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -112,8 +112,9 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -126,13 +127,12 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -143,14 +143,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -163,20 +166,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -192,8 +193,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -206,15 +208,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -228,9 +229,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -243,20 +247,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -268,9 +270,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -283,18 +288,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -309,9 +312,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -323,24 +329,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -354,8 +358,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -368,15 +373,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -388,8 +392,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -402,13 +407,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -420,8 +424,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -434,13 +439,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -452,8 +456,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -466,13 +471,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -486,9 +490,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -501,20 +508,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -526,8 +531,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -540,13 +546,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -558,8 +563,9 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -572,13 +578,12 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -589,14 +594,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -609,63 +617,62 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -681,11 +688,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -708,7 +717,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -735,17 +744,20 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -753,6 +765,8 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -762,8 +776,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -783,13 +803,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -799,11 +822,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -849,21 +874,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -873,8 +903,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -894,13 +930,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -910,11 +949,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -961,21 +1002,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -985,8 +1031,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1004,17 +1056,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -1027,11 +1082,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1062,9 +1119,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1090,17 +1147,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1108,20 +1168,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1142,13 +1209,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1159,11 +1229,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1212,22 +1284,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1237,8 +1314,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1259,7 +1342,7 @@ def get( instance_id: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1277,13 +1360,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1294,11 +1380,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1326,7 +1414,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1340,13 +1428,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1356,11 +1447,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1390,7 +1483,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1414,13 +1507,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1433,9 +1529,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1448,9 +1546,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1491,13 +1591,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1508,11 +1611,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1564,22 +1669,27 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1589,8 +1699,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1610,13 +1726,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1626,11 +1745,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1675,21 +1796,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1699,8 +1825,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1720,13 +1852,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1736,11 +1871,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1785,21 +1922,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1809,8 +1951,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1830,13 +1978,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1846,11 +1997,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1896,21 +2049,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1920,8 +2078,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1942,7 +2106,7 @@ def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -1961,13 +2125,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1978,11 +2145,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2010,13 +2179,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2026,11 +2198,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2075,21 +2249,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2099,8 +2278,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2134,13 +2319,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2150,11 +2338,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2176,18 +2366,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2200,11 +2393,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2233,11 +2428,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2248,7 +2443,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2264,16 +2459,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2281,20 +2479,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_sets_operations.py index 9db71faee863..69b983d10e6c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -159,8 +162,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,15 +176,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -193,9 +196,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -207,20 +213,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -230,13 +234,15 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -248,19 +254,17 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -272,14 +276,16 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -291,21 +297,19 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -318,9 +322,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -332,18 +339,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -353,9 +358,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -366,18 +374,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -386,9 +392,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -398,18 +407,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -420,9 +427,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -434,18 +444,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -456,9 +464,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -470,18 +481,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -491,14 +500,16 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -510,21 +521,19 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -536,13 +545,15 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -554,19 +565,17 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -578,13 +587,15 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -596,19 +607,17 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -620,13 +629,15 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -638,19 +649,17 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -662,13 +671,15 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -680,19 +691,17 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -704,13 +713,15 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -722,19 +733,17 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -746,13 +755,15 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -764,19 +775,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -788,13 +797,15 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -806,19 +817,17 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -833,9 +842,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( platform_update_domain: int, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -847,19 +859,17 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -869,13 +879,15 @@ def build_convert_to_single_placement_group_request( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VMScaleSetConvertToSinglePlacementGroupInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup") # pylint: disable=line-too-long path_format_arguments = { @@ -887,19 +899,17 @@ def build_convert_to_single_placement_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -911,13 +921,15 @@ def build_set_orchestration_service_state_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.OrchestrationServiceStateInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState") # pylint: disable=line-too-long path_format_arguments = { @@ -929,52 +941,48 @@ def build_set_orchestration_service_state_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. @@ -986,13 +994,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1001,9 +1012,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -1012,9 +1025,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1051,17 +1066,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -1073,11 +1091,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1107,9 +1127,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1132,37 +1152,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1179,17 +1209,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -1201,11 +1234,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1231,9 +1266,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1256,37 +1291,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1306,13 +1351,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1322,11 +1370,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1372,21 +1422,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1396,8 +1451,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1417,7 +1478,7 @@ def get( vm_scale_set_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1433,13 +1494,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1449,11 +1513,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1478,17 +1544,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1503,11 +1572,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1529,7 +1600,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1556,23 +1627,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1582,8 +1658,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1600,18 +1682,21 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1624,11 +1709,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements json=_json, force_deletion=force_deletion, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1650,7 +1737,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: @@ -1678,17 +1765,20 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, @@ -1696,6 +1786,8 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1705,8 +1797,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1725,7 +1823,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1737,13 +1835,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1752,11 +1853,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1782,7 +1885,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1794,13 +1897,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1809,9 +1915,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1820,9 +1928,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1859,7 +1969,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1871,13 +1981,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1885,9 +1998,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1895,9 +2010,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1936,7 +2053,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1951,13 +2068,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1967,9 +2087,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1979,9 +2101,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2020,7 +2144,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -2034,13 +2158,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2050,9 +2177,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2062,9 +2191,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2102,17 +2233,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2128,11 +2262,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2155,7 +2291,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -2186,17 +2322,20 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -2204,6 +2343,8 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2213,8 +2354,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2231,17 +2378,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2256,11 +2406,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2282,7 +2434,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2307,23 +2459,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2333,8 +2490,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2351,17 +2514,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2376,11 +2542,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2402,7 +2570,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2427,23 +2595,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2453,8 +2626,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2471,17 +2650,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2496,11 +2678,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2522,7 +2706,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2548,23 +2732,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2574,8 +2763,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2592,17 +2787,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2617,11 +2815,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2643,7 +2843,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2671,23 +2871,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2697,8 +2902,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2715,17 +2926,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2737,11 +2951,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2763,7 +2979,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2787,23 +3003,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2813,8 +3034,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2831,17 +3058,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -2856,11 +3086,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2882,7 +3114,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -2908,23 +3140,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2934,8 +3171,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2952,17 +3195,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2977,11 +3223,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3003,7 +3251,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -3029,23 +3277,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -3055,8 +3308,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -3076,7 +3335,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( vm_scale_set_name: str, platform_update_domain: int, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -3092,13 +3351,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -3108,11 +3370,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( api_version=api_version, platform_update_domain=platform_update_domain, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3138,7 +3402,7 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -3155,14 +3419,17 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st :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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -3174,11 +3441,13 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3199,17 +3468,20 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'OrchestrationServiceStateInput') @@ -3221,11 +3493,13 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3247,7 +3521,7 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> LROPoller[None]: """Changes ServiceState property for a given service. @@ -3270,23 +3544,28 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._set_orchestration_service_state_initial( + raw_result = self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -3296,8 +3575,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_sizes_operations.py index 6439a7c0951e..b7c7b57f20c4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -99,13 +99,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machines_operations.py index 6afeba789405..31137e64591f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_07_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -203,8 +207,9 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -216,15 +221,14 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -237,9 +241,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -251,20 +258,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -275,9 +280,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -289,18 +297,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -311,8 +317,9 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -324,13 +331,12 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -343,8 +349,9 @@ def build_deallocate_request_initial( hibernate: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -356,15 +363,14 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if hibernate is not None: - _query_parameters['hibernate'] = _SERIALIZER.query("hibernate", hibernate, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['hibernate'] = _SERIALIZER.query("hibernate", hibernate, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -375,8 +381,9 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -388,13 +395,12 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -404,9 +410,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -417,18 +426,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -439,9 +446,12 @@ def build_list_all_request( status_only: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -451,20 +461,18 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 status_only is not None: - _query_parameters['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') + _params['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -475,9 +483,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -489,18 +500,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -513,8 +522,9 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -526,15 +536,14 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, + params=_params, **kwargs ) @@ -545,9 +554,12 @@ def build_reapply_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply") # pylint: disable=line-too-long path_format_arguments = { @@ -559,18 +571,16 @@ def build_reapply_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -581,8 +591,9 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -594,13 +605,12 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -611,8 +621,9 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -624,13 +635,12 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -641,8 +651,9 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -654,13 +665,12 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -670,13 +680,15 @@ def build_reimage_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -688,19 +700,17 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -715,9 +725,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -729,20 +742,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -753,8 +764,9 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -766,13 +778,12 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -783,8 +794,9 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -796,13 +808,12 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -813,9 +824,12 @@ def build_assess_patches_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -827,18 +841,16 @@ def build_assess_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -848,14 +860,17 @@ def build_install_patches_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineInstallPatchesParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -867,20 +882,18 @@ def build_install_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -892,14 +905,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -911,53 +927,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2021_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2021_07_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -969,13 +981,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -984,9 +999,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -995,9 +1012,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1034,17 +1053,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -1056,11 +1078,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1088,9 +1112,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -1114,37 +1138,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -1161,17 +1195,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -1183,11 +1220,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1217,9 +1256,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -1242,37 +1281,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1289,17 +1338,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1311,11 +1363,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1341,9 +1395,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1365,37 +1419,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1415,13 +1479,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1431,11 +1498,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1481,21 +1550,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1505,8 +1579,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1526,7 +1606,7 @@ def get( vm_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1544,13 +1624,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1560,11 +1643,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1591,7 +1676,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1603,13 +1688,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2021_07_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1618,11 +1706,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1649,13 +1739,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1664,11 +1757,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1711,20 +1806,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1734,8 +1834,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1755,13 +1861,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements hibernate: Optional[bool] = None, **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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -1771,11 +1880,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, hibernate=hibernate, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1822,21 +1933,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, hibernate=hibernate, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1846,8 +1962,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1883,13 +2005,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1898,11 +2023,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1924,7 +2051,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1937,13 +2064,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1952,9 +2082,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1963,9 +2095,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2003,7 +2137,7 @@ def list_all( self, status_only: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -2017,13 +2151,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2032,9 +2169,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2043,9 +2182,11 @@ def prepare_request(next_link=None): api_version=api_version, status_only=status_only, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2084,7 +2225,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -2099,13 +2240,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2115,9 +2259,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2127,9 +2273,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2169,13 +2317,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -2185,11 +2336,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2237,21 +2390,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2261,8 +2419,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2281,13 +2445,16 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -2296,11 +2463,13 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2342,20 +2511,25 @@ def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reapply_initial( + raw_result = self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2365,8 +2539,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2385,13 +2565,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2400,11 +2583,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2446,20 +2631,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2469,8 +2659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2489,13 +2685,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2504,11 +2703,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2550,20 +2751,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2573,8 +2779,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2593,13 +2805,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2608,11 +2823,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2654,20 +2871,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2677,8 +2899,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2695,17 +2923,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -2720,11 +2951,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2746,7 +2979,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -2770,23 +3003,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -2796,8 +3034,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2817,7 +3061,7 @@ def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -2833,13 +3077,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_07_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -2849,11 +3096,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2880,13 +3129,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2895,11 +3147,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2941,20 +3195,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2964,8 +3223,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2996,13 +3261,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -3011,11 +3279,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3037,14 +3307,17 @@ def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -3053,11 +3326,13 @@ def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3086,7 +3361,7 @@ def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -3107,34 +3382,44 @@ def begin_assess_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -3151,17 +3436,20 @@ def _install_patches_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineInstallPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineInstallPatchesResult"]] + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineInstallPatchesResult]] _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') @@ -3173,11 +3461,13 @@ def _install_patches_initial( content_type=content_type, json=_json, template_url=self._install_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3205,9 +3495,9 @@ def begin_install_patches( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineInstallPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. @@ -3231,37 +3521,47 @@ def begin_install_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.VirtualMachineInstallPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstallPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstallPatchesResult"] 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._install_patches_initial( + raw_result = self._install_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineInstallPatchesResult', 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( @@ -3278,18 +3578,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -3301,11 +3604,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3333,11 +3638,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -3346,7 +3651,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_07_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -3362,36 +3667,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_07_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/_compute_management_client.py index 4ce4ebbb696a..5f66a8c23856 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/_compute_management_client.py @@ -65,11 +65,21 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_restore_point = DiskRestorePointOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/_compute_management_client.py index 52f9bb063cef..827741deb369 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/_compute_management_client.py @@ -65,11 +65,21 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_restore_point = DiskRestorePointOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/__init__.py index c3e7f3bd4f2e..332fb79d2c68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/__init__.py @@ -12,6 +12,9 @@ from ._disk_accesses_operations import DiskAccessesOperations from ._disk_restore_point_operations import DiskRestorePointOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', @@ -19,3 +22,5 @@ 'DiskAccessesOperations', 'DiskRestorePointOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disk_accesses_operations.py index f692e6cf64d6..ddcc4137e680 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskAccessesOperations: - """DiskAccessesOperations async operations. - - You 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.compute.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.compute.v2021_08_01.aio.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_08_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_08_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_08_01.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -340,11 +372,13 @@ async def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -626,7 +690,7 @@ async def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -640,13 +704,16 @@ async def get_private_link_resources( :rtype: ~azure.mgmt.compute.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', "2021-08-01") # 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.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -655,11 +722,13 @@ async def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -685,17 +754,20 @@ async def _update_a_private_endpoint_connection_initial( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - 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(private_endpoint_connection, 'PrivateEndpointConnection') @@ -708,11 +780,13 @@ async def _update_a_private_endpoint_connection_initial( content_type=content_type, json=_json, template_url=self._update_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -743,9 +817,9 @@ async def begin_update_a_private_endpoint_connection( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection under disk access resource, this can't be used to create a new private endpoint connection. @@ -775,17 +849,20 @@ async def begin_update_a_private_endpoint_connection( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_08_01.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_a_private_endpoint_connection_initial( + raw_result = await self._update_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -793,20 +870,27 @@ async def begin_update_a_private_endpoint_connection( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -826,7 +910,7 @@ async def get_a_private_endpoint_connection( disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about a private endpoint connection under a disk access resource. :param resource_group_name: The name of the resource group. @@ -842,13 +926,16 @@ async def get_a_private_endpoint_connection( :rtype: ~azure.mgmt.compute.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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_a_private_endpoint_connection_request( @@ -858,11 +945,13 @@ async def get_a_private_endpoint_connection( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get_a_private_endpoint_connection.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -890,13 +979,16 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inco private_endpoint_connection_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', "2021-08-01") # type: str + 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_a_private_endpoint_connection_request_initial( @@ -906,11 +998,13 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inco private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -957,21 +1051,26 @@ async def begin_delete_a_private_endpoint_connection( # pylint: disable=inconsi :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_a_private_endpoint_connection_initial( + raw_result = await self._delete_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -981,8 +1080,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1001,7 +1106,7 @@ def list_private_endpoint_connections( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List information about private endpoint connections under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1017,13 +1122,16 @@ def list_private_endpoint_connections( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_08_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - 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: @@ -1033,9 +1141,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=self.list_private_endpoint_connections.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1045,9 +1155,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disk_encryption_sets_operations.py index e60958a6bd81..bc03c3d85072 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskEncryptionSetsOperations: - """DiskEncryptionSetsOperations async operations. - - You 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.compute.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.compute.v2021_08_01.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - 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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -238,9 +257,9 @@ async def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -266,37 +285,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -315,7 +344,7 @@ async def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -329,13 +358,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # 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.DiskEncryptionSet] request = build_get_request( @@ -344,11 +376,13 @@ async def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -375,13 +409,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -390,11 +427,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,20 +477,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -461,8 +505,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -480,7 +530,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -492,13 +542,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -507,9 +560,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -518,9 +573,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -557,7 +614,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -567,13 +624,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -581,9 +641,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -591,9 +653,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -632,7 +696,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceUriList"]: + ) -> AsyncIterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -647,13 +711,16 @@ def list_associated_resources( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_08_01.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -663,9 +730,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_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,9 +744,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disk_restore_point_operations.py index d30854fcd974..7d84ce0c2c17 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disk_restore_point_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskRestorePointOperations: - """DiskRestorePointOperations async operations. - - You 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.compute.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.compute.v2021_08_01.aio.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -55,7 +54,7 @@ async def get( vm_restore_point_name: str, disk_restore_point_name: str, **kwargs: Any - ) -> "_models.DiskRestorePoint": + ) -> _models.DiskRestorePoint: """Get disk restorePoint resource. :param resource_group_name: The name of the resource group. @@ -73,13 +72,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_08_01.models.DiskRestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePoint] request = build_get_request( @@ -90,11 +92,13 @@ async def get( disk_restore_point_name=disk_restore_point_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -122,7 +126,7 @@ def list_by_restore_point( restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskRestorePointList"]: + ) -> AsyncIterable[_models.DiskRestorePointList]: """Lists diskRestorePoints under a vmRestorePoint. :param resource_group_name: The name of the resource group. @@ -140,13 +144,16 @@ def list_by_restore_point( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskRestorePointList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePointList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePointList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -157,9 +164,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=self.list_by_restore_point.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -170,9 +179,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -211,17 +222,20 @@ async def _grant_access_initial( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -235,11 +249,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -269,9 +285,9 @@ async def begin_grant_access( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a diskRestorePoint. :param resource_group_name: The name of the resource group. @@ -300,17 +316,20 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_08_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, @@ -319,20 +338,27 @@ async def begin_grant_access( 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('AccessUri', 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( @@ -353,13 +379,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_restore_point_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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -370,11 +399,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_restore_point_name=disk_restore_point_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -424,22 +455,27 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, disk_restore_point_name=disk_restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -449,8 +485,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disks_operations.py index 6b6c7691865f..039a69d3afaf 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.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.compute.v2021_08_01.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_08_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - 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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_08_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_08_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_08_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_snapshots_operations.py index 8c0a371f965b..44a3c351b4c0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.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.compute.v2021_08_01.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_08_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - 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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_08_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_08_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_08_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_08_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_08_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/__init__.py index d3a120e354e8..e6e01f613586 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/__init__.py @@ -72,7 +72,9 @@ PublicNetworkAccess, SnapshotStorageAccountTypes, ) - +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__ = [ 'AccessUri', 'ApiError', @@ -137,3 +139,5 @@ 'PublicNetworkAccess', 'SnapshotStorageAccountTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/_compute_management_client_enums.py index 17a26864da82..4f83af580874 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/_compute_management_client_enums.py @@ -7,17 +7,16 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" WRITE = "Write" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -50,7 +49,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: disk and upload using write token in both disk and VM guest state. UPLOAD_PREPARED_SECURE = "UploadPreparedSecure" -class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted resources @@ -60,7 +59,7 @@ class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, SYSTEM_ASSIGNED = "SystemAssigned" NONE = "None" -class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -73,7 +72,7 @@ class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Confidential VM supported disk and VM guest state would be encrypted with customer managed key. CONFIDENTIAL_VM_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVmEncryptedWithCustomerKey" -class DiskSecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskSecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the SecurityType of the VM. Applicable for OS disks only. """ @@ -89,7 +88,7 @@ class DiskSecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: managed key. CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVM_DiskEncryptedWithCustomerKey" -class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible state of the disk. """ @@ -110,7 +109,7 @@ class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: A disk is created for upload and a write token has been issued for uploading to it. ACTIVE_UPLOAD = "ActiveUpload" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -131,7 +130,7 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: and dev/test that need storage resiliency against zone failures. STANDARD_SSD_ZRS = "StandardSSD_ZRS" -class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -145,20 +144,20 @@ class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the other key is Platform managed. ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Policy for accessing the disk via network. """ @@ -169,14 +168,14 @@ class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The disk cannot be exported. DENY_ALL = "DenyAll" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -185,7 +184,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. """ @@ -193,7 +192,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Policy for controlling export on the disk. """ @@ -206,7 +205,7 @@ class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate. DISABLED = "Disabled" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/_models_py3.py index b05f3a6fc1e4..5b0235dfd7ad 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -71,8 +73,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -144,9 +146,9 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", - "CopyStart", "ImportSecure", "UploadPreparedSecure". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart", + "ImportSecure", "UploadPreparedSecure". :vartype create_option: str or ~azure.mgmt.compute.v2021_08_01.models.DiskCreateOption :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -199,10 +201,10 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, - gallery_image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, + gallery_image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, upload_size_bytes: Optional[int] = None, @@ -212,7 +214,7 @@ def __init__( ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart", "ImportSecure", "UploadPreparedSecure". :paramtype create_option: str or ~azure.mgmt.compute.v2021_08_01.models.DiskCreateOption :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager @@ -342,10 +344,10 @@ class Disk(Resource): :vartype extended_location: ~azure.mgmt.compute.v2021_08_01.models.ExtendedLocation :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_08_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_08_01.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: @@ -386,7 +388,7 @@ class Disk(Resource): mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. :vartype disk_m_bps_read_only: long - :ivar disk_state: The state of the disk. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2021_08_01.models.DiskState :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed @@ -398,8 +400,8 @@ class Disk(Resource): :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should be set to a value greater than one for disks to allow attaching them to multiple VMs. :vartype share_info: list[~azure.mgmt.compute.v2021_08_01.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_08_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -421,8 +423,8 @@ class Disk(Resource): :ivar completion_percent: Percentage complete for the background copy when a resource is created via the CopyStart operation. :vartype completion_percent: float - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_08_01.models.PublicNetworkAccess """ @@ -489,30 +491,30 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, - creation_data: Optional["CreationData"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, supports_hibernation: Optional[bool] = None, - security_profile: Optional["DiskSecurityProfile"] = None, + security_profile: Optional["_models.DiskSecurityProfile"] = None, completion_percent: Optional[float] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, **kwargs ): """ @@ -528,10 +530,10 @@ def __init__( :keyword extended_location: The extended location where the disk will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2021_08_01.models.ExtendedLocation - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_08_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_08_01.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: @@ -572,8 +574,8 @@ def __init__( :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_08_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -593,8 +595,8 @@ def __init__( :keyword completion_percent: Percentage complete for the background copy when a resource is created via the CopyStart operation. :paramtype completion_percent: float - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_08_01.models.PublicNetworkAccess """ @@ -691,7 +693,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, **kwargs ): """ @@ -734,7 +736,7 @@ class DiskAccessList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskAccess"], + value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs ): @@ -795,8 +797,8 @@ class DiskEncryptionSet(Resource): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2021_08_01.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", "ConfidentialVmEncryptedWithCustomerKey". :vartype encryption_type: str or ~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSetType :ivar active_key: The key vault key which is currently used by this disk encryption set. @@ -851,9 +853,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyForDiskEncryptionSet"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, rotation_to_latest_key_version_enabled: Optional[bool] = None, **kwargs ): @@ -865,8 +867,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2021_08_01.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", "ConfidentialVmEncryptedWithCustomerKey". :paramtype encryption_type: str or ~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSetType :keyword active_key: The key vault key which is currently used by this disk encryption set. @@ -910,7 +912,7 @@ class DiskEncryptionSetList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskEncryptionSet"], + value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs ): @@ -934,8 +936,8 @@ class DiskEncryptionSetUpdate(msrest.serialization.Model): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2021_08_01.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", "ConfidentialVmEncryptedWithCustomerKey". :vartype encryption_type: str or ~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSetType :ivar active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and @@ -958,9 +960,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyForDiskEncryptionSet"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, rotation_to_latest_key_version_enabled: Optional[bool] = None, **kwargs ): @@ -970,8 +972,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2021_08_01.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", "ConfidentialVmEncryptedWithCustomerKey". :paramtype encryption_type: str or ~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSetType :keyword active_key: Key Vault Key Url to be used for server side encryption of Managed Disks @@ -1013,7 +1015,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -1081,10 +1083,10 @@ class DiskRestorePoint(ProxyOnlyResource): :vartype time_created: ~datetime.datetime :ivar source_resource_id: arm id of source disk or source disk restore point. :vartype source_resource_id: str - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_08_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_08_01.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. @@ -1101,12 +1103,12 @@ class DiskRestorePoint(ProxyOnlyResource): :vartype encryption: ~azure.mgmt.compute.v2021_08_01.models.Encryption :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. :vartype supports_hibernation: bool - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_08_01.models.NetworkAccessPolicy - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_08_01.models.PublicNetworkAccess :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -1161,19 +1163,19 @@ class DiskRestorePoint(ProxyOnlyResource): def __init__( self, *, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, supports_hibernation: Optional[bool] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, disk_access_id: Optional[str] = None, completion_percent: Optional[float] = None, **kwargs ): """ :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_08_01.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. @@ -1183,12 +1185,12 @@ def __init__( :paramtype supported_capabilities: ~azure.mgmt.compute.v2021_08_01.models.SupportedCapabilities :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. :paramtype supports_hibernation: bool - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_08_01.models.NetworkAccessPolicy - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_08_01.models.PublicNetworkAccess :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -1241,7 +1243,7 @@ class DiskRestorePointList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskRestorePoint"], + value: List["_models.DiskRestorePoint"], next_link: Optional[str] = None, **kwargs ): @@ -1260,9 +1262,8 @@ def __init__( class DiskSecurityProfile(msrest.serialization.Model): """Contains the security related information for the resource. - :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Possible values include: "TrustedLaunch", - "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", + :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. Known + values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithCustomerKey". :vartype security_type: str or ~azure.mgmt.compute.v2021_08_01.models.DiskSecurityTypes :ivar secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to @@ -1278,14 +1279,13 @@ class DiskSecurityProfile(msrest.serialization.Model): def __init__( self, *, - security_type: Optional[Union[str, "DiskSecurityTypes"]] = None, + security_type: Optional[Union[str, "_models.DiskSecurityTypes"]] = None, secure_vm_disk_encryption_set_id: Optional[str] = None, **kwargs ): """ :keyword security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Possible values include: "TrustedLaunch", - "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", + Known values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithCustomerKey". :paramtype security_type: str or ~azure.mgmt.compute.v2021_08_01.models.DiskSecurityTypes :keyword secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to @@ -1302,8 +1302,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype name: str or ~azure.mgmt.compute.v2021_08_01.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -1321,11 +1321,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2021_08_01.models.DiskStorageAccountTypes """ @@ -1344,7 +1344,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, or StandardSSD_ZRS. :vartype sku: ~azure.mgmt.compute.v2021_08_01.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_08_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1375,8 +1375,8 @@ class DiskUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2021_08_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_08_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -1398,8 +1398,8 @@ class DiskUpdate(msrest.serialization.Model): ~azure.mgmt.compute.v2021_08_01.models.PropertyUpdatesInProgress :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_08_01.models.PublicNetworkAccess """ @@ -1435,24 +1435,24 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, max_shares: Optional[int] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, - purchase_plan: Optional["PurchasePlan"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, **kwargs ): """ @@ -1461,7 +1461,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, or StandardSSD_ZRS. :paramtype sku: ~azure.mgmt.compute.v2021_08_01.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_08_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1492,8 +1492,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2021_08_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_08_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -1513,8 +1513,8 @@ def __init__( :paramtype supported_capabilities: ~azure.mgmt.compute.v2021_08_01.models.SupportedCapabilities :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_08_01.models.PublicNetworkAccess """ @@ -1547,7 +1547,7 @@ class Encryption(msrest.serialization.Model): :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Possible values include: + :ivar type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype type: str or ~azure.mgmt.compute.v2021_08_01.models.EncryptionType @@ -1562,14 +1562,14 @@ def __init__( self, *, disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "EncryptionType"]] = None, + type: Optional[Union[str, "_models.EncryptionType"]] = None, **kwargs ): """ :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Possible values include: + :keyword type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype type: str or ~azure.mgmt.compute.v2021_08_01.models.EncryptionType @@ -1587,7 +1587,7 @@ class EncryptionSetIdentity(msrest.serialization.Model): :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted - resources to lose access to the keys. Possible values include: "SystemAssigned", "None". + resources to lose access to the keys. Known values are: "SystemAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSetIdentityType :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a @@ -1613,15 +1613,14 @@ class EncryptionSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "DiskEncryptionSetIdentityType"]] = None, + type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, **kwargs ): """ :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the - encrypted resources to lose access to the keys. Possible values include: "SystemAssigned", - "None". + encrypted resources to lose access to the keys. Known values are: "SystemAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSetIdentityType """ super(EncryptionSetIdentity, self).__init__(**kwargs) @@ -1663,7 +1662,7 @@ def __init__( self, *, enabled: bool, - encryption_settings: Optional[List["EncryptionSettingsElement"]] = None, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, encryption_settings_version: Optional[str] = None, **kwargs ): @@ -1705,8 +1704,8 @@ class EncryptionSettingsElement(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -1727,7 +1726,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.compute.v2021_08_01.models.ExtendedLocationTypes """ @@ -1740,13 +1739,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.compute.v2021_08_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -1759,7 +1758,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read", "Write". + :ivar access: Required. Known values are: "None", "Read", "Write". :vartype access: str or ~azure.mgmt.compute.v2021_08_01.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -1782,13 +1781,13 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, get_secure_vm_guest_state_sas: Optional[bool] = None, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read", "Write". + :keyword access: Required. Known values are: "None", "Read", "Write". :paramtype access: str or ~azure.mgmt.compute.v2021_08_01.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -1903,7 +1902,7 @@ def __init__( self, *, key_url: str, - source_vault: Optional["SourceVault"] = None, + source_vault: Optional["_models.SourceVault"] = None, **kwargs ): """ @@ -1944,7 +1943,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -1983,7 +1982,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -2043,7 +2042,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype private_link_service_connection_state: ~azure.mgmt.compute.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.compute.v2021_08_01.models.PrivateEndpointConnectionProvisioningState """ @@ -2068,7 +2067,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): def __init__( self, *, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -2104,7 +2103,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2189,7 +2188,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -2204,7 +2203,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.compute.v2021_08_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -2223,14 +2222,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, actions_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.compute.v2021_08_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -2425,10 +2424,10 @@ class Snapshot(Resource): :vartype extended_location: ~azure.mgmt.compute.v2021_08_01.models.ExtendedLocation :ivar time_created: The time when the snapshot was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_08_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_08_01.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. @@ -2446,7 +2445,7 @@ class Snapshot(Resource): :vartype disk_size_gb: int :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. :vartype disk_size_bytes: long - :ivar disk_state: The state of the snapshot. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the snapshot. Known values are: "Unattached", "Attached", "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2021_08_01.models.DiskState :ivar unique_id: Unique Guid identifying the resource. @@ -2463,8 +2462,8 @@ class Snapshot(Resource): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2021_08_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_08_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -2473,8 +2472,8 @@ class Snapshot(Resource): :vartype security_profile: ~azure.mgmt.compute.v2021_08_01.models.DiskSecurityProfile :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_08_01.models.PublicNetworkAccess :ivar completion_percent: Percentage complete for the background copy when a resource is @@ -2531,22 +2530,22 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - extended_location: Optional["ExtendedLocation"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, incremental: Optional[bool] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, - security_profile: Optional["DiskSecurityProfile"] = None, + security_profile: Optional["_models.DiskSecurityProfile"] = None, supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, completion_percent: Optional[float] = None, **kwargs ): @@ -2562,10 +2561,10 @@ def __init__( :keyword extended_location: The extended location where the snapshot will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2021_08_01.models.ExtendedLocation - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_08_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_08_01.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. @@ -2591,8 +2590,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2021_08_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_08_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -2602,8 +2601,8 @@ def __init__( :paramtype security_profile: ~azure.mgmt.compute.v2021_08_01.models.DiskSecurityProfile :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_08_01.models.PublicNetworkAccess :keyword completion_percent: Percentage complete for the background copy when a resource is @@ -2660,7 +2659,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -2681,8 +2680,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2021_08_01.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -2700,12 +2698,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2021_08_01.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -2722,7 +2719,7 @@ class SnapshotUpdate(msrest.serialization.Model): an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. :vartype sku: ~azure.mgmt.compute.v2021_08_01.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_08_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -2736,16 +2733,16 @@ class SnapshotUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2021_08_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_08_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. :vartype disk_access_id: str :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_08_01.models.PublicNetworkAccess :ivar supported_capabilities: List of supported capabilities (like accelerated networking) for @@ -2771,16 +2768,16 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, **kwargs ): """ @@ -2790,7 +2787,7 @@ def __init__( is an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. :paramtype sku: ~azure.mgmt.compute.v2021_08_01.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_08_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -2804,8 +2801,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2021_08_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_08_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -2813,8 +2810,8 @@ def __init__( :paramtype disk_access_id: str :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_08_01.models.PublicNetworkAccess :keyword supported_capabilities: List of supported capabilities (like accelerated networking) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/__init__.py index c3e7f3bd4f2e..332fb79d2c68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/__init__.py @@ -12,6 +12,9 @@ from ._disk_accesses_operations import DiskAccessesOperations from ._disk_restore_point_operations import DiskRestorePointOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', @@ -19,3 +22,5 @@ 'DiskAccessesOperations', 'DiskRestorePointOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disk_accesses_operations.py index 52033d5ad6eb..005bc19ef950 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccess] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccessUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_get_private_link_resources_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,18 +284,16 @@ def build_get_private_link_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -297,14 +304,17 @@ def build_update_a_private_endpoint_connection_request_initial( disk_access_name: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -317,20 +327,18 @@ def build_update_a_private_endpoint_connection_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -344,9 +352,12 @@ def build_get_a_private_endpoint_connection_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -359,18 +370,16 @@ def build_get_a_private_endpoint_connection_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -382,9 +391,12 @@ def build_delete_a_private_endpoint_connection_request_initial( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -397,18 +409,16 @@ def build_delete_a_private_endpoint_connection_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -419,9 +429,12 @@ def build_list_private_endpoint_connections_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections") # pylint: disable=line-too-long path_format_arguments = { @@ -433,58 +446,57 @@ def build_list_private_endpoint_connections_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskAccessesOperations(object): - """DiskAccessesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_08_01.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -496,11 +508,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,9 +544,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -555,37 +569,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_08_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -602,17 +626,20 @@ def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - 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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -624,11 +651,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -658,9 +687,9 @@ def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -683,37 +712,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_08_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -732,7 +771,7 @@ def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -746,13 +785,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_08_01.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # 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.DiskAccess] request = build_get_request( @@ -761,11 +803,13 @@ def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -792,13 +836,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -807,11 +854,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -855,20 +904,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -878,8 +932,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -897,7 +957,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -907,13 +967,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -922,9 +985,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -933,9 +998,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -972,7 +1039,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -980,13 +1047,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -994,9 +1064,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1004,9 +1076,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1045,7 +1119,7 @@ def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -1059,13 +1133,16 @@ def get_private_link_resources( :rtype: ~azure.mgmt.compute.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', "2021-08-01") # 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.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -1074,11 +1151,13 @@ def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1104,17 +1183,20 @@ def _update_a_private_endpoint_connection_initial( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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(private_endpoint_connection, 'PrivateEndpointConnection') @@ -1127,11 +1209,13 @@ def _update_a_private_endpoint_connection_initial( content_type=content_type, json=_json, template_url=self._update_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1162,9 +1246,9 @@ def begin_update_a_private_endpoint_connection( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection under disk access resource, this can't be used to create a new private endpoint connection. @@ -1194,17 +1278,20 @@ def begin_update_a_private_endpoint_connection( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_08_01.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_a_private_endpoint_connection_initial( + raw_result = self._update_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -1212,20 +1299,27 @@ def begin_update_a_private_endpoint_connection( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -1245,7 +1339,7 @@ def get_a_private_endpoint_connection( disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about a private endpoint connection under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1261,13 +1355,16 @@ def get_a_private_endpoint_connection( :rtype: ~azure.mgmt.compute.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', "2021-08-01") # 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.PrivateEndpointConnection] request = build_get_a_private_endpoint_connection_request( @@ -1277,11 +1374,13 @@ def get_a_private_endpoint_connection( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get_a_private_endpoint_connection.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1309,13 +1408,16 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsiste private_endpoint_connection_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', "2021-08-01") # type: str + 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_a_private_endpoint_connection_request_initial( @@ -1325,11 +1427,13 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsiste private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1376,21 +1480,26 @@ def begin_delete_a_private_endpoint_connection( # pylint: disable=inconsistent- :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_a_private_endpoint_connection_initial( + raw_result = self._delete_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1400,8 +1509,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1420,7 +1535,7 @@ def list_private_endpoint_connections( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List information about private endpoint connections under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1436,13 +1551,16 @@ def list_private_endpoint_connections( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_08_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - 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: @@ -1452,9 +1570,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=self.list_private_endpoint_connections.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1464,9 +1584,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disk_encryption_sets_operations.py index ca1310917fe3..ce99e825ac4f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_list_associated_resources_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,58 +284,57 @@ def build_list_associated_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskEncryptionSetsOperations(object): - """DiskEncryptionSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_08_01.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - 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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -338,11 +346,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -372,9 +382,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -399,37 +409,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -446,17 +466,20 @@ def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -468,11 +491,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,9 +527,9 @@ def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -529,37 +554,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -578,7 +613,7 @@ def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -592,13 +627,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # 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.DiskEncryptionSet] request = build_get_request( @@ -607,11 +645,13 @@ def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -638,13 +678,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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', "2021-08-01") # type: str + 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_initial( @@ -653,11 +696,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -701,20 +746,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -724,8 +774,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -743,7 +799,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -755,13 +811,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -770,9 +829,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -781,9 +842,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -820,7 +883,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -830,13 +893,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -844,9 +910,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -854,9 +922,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -895,7 +965,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> Iterable["_models.ResourceUriList"]: + ) -> Iterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -909,13 +979,16 @@ def list_associated_resources( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_08_01.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -925,9 +998,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -937,9 +1012,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disk_restore_point_operations.py index febef73d8905..b283d3f8292b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disk_restore_point_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +37,12 @@ def build_get_request( disk_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,18 +56,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -76,9 +77,12 @@ def build_list_by_restore_point_request( vm_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints") # pylint: disable=line-too-long path_format_arguments = { @@ -91,18 +95,16 @@ def build_list_by_restore_point_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -114,14 +116,17 @@ def build_grant_access_request_initial( vm_restore_point_name: str, disk_restore_point_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -135,20 +140,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -163,9 +166,12 @@ def build_revoke_access_request_initial( disk_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -179,42 +185,38 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class DiskRestorePointOperations(object): - """DiskRestorePointOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskRestorePointOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_08_01.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -224,7 +226,7 @@ def get( vm_restore_point_name: str, disk_restore_point_name: str, **kwargs: Any - ) -> "_models.DiskRestorePoint": + ) -> _models.DiskRestorePoint: """Get disk restorePoint resource. :param resource_group_name: The name of the resource group. @@ -242,13 +244,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_08_01.models.DiskRestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # 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.DiskRestorePoint] request = build_get_request( @@ -259,11 +264,13 @@ def get( disk_restore_point_name=disk_restore_point_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -291,7 +298,7 @@ def list_by_restore_point( restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> Iterable["_models.DiskRestorePointList"]: + ) -> Iterable[_models.DiskRestorePointList]: """Lists diskRestorePoints under a vmRestorePoint. :param resource_group_name: The name of the resource group. @@ -309,13 +316,16 @@ def list_by_restore_point( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskRestorePointList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePointList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePointList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -326,9 +336,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=self.list_by_restore_point.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -339,9 +351,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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,17 +394,20 @@ def _grant_access_initial( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -404,11 +421,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,9 +457,9 @@ def begin_grant_access( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a diskRestorePoint. :param resource_group_name: The name of the resource group. @@ -468,17 +487,20 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_08_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, @@ -487,20 +509,27 @@ def begin_grant_access( 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('AccessUri', 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( @@ -521,13 +550,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_restore_point_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', "2021-08-01") # type: str + 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_access_request_initial( @@ -538,11 +570,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_restore_point_name=disk_restore_point_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -592,22 +626,27 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, disk_restore_point_name=disk_restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -617,8 +656,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disks_operations.py index 9e7a8a1f5839..6f46d35a178e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _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.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _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.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_08_01.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_08_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_08_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_08_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_08_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_08_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2021-08-01") # type: str + 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_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_snapshots_operations.py index b877038d2e2d..76adbe5eb7f8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_08_01/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _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.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_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") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _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.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.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.compute.v2021_08_01.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_08_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_08_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_08_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_08_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_08_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_08_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2021-08-01") # type: str + 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_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-08-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_compute_management_client.py index 4da7a2d20344..4f7ee54af57f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_compute_management_client.py @@ -69,12 +69,24 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_sharing_profile = GallerySharingProfileOperations(self._client, self._config, self._serialize, self._deserialize) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_sharing_profile = GallerySharingProfileOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/_compute_management_client.py index 60675c5a4926..9e52b2be8a52 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/_compute_management_client.py @@ -69,12 +69,24 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_sharing_profile = GallerySharingProfileOperations(self._client, self._config, self._serialize, self._deserialize) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_sharing_profile = GallerySharingProfileOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/__init__.py index 8e08b35d1064..7e5da4070f2b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/__init__.py @@ -13,6 +13,9 @@ from ._gallery_application_versions_operations import GalleryApplicationVersionsOperations from ._gallery_sharing_profile_operations import GallerySharingProfileOperations +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__ = [ 'GalleriesOperations', 'GalleryImagesOperations', @@ -21,3 +24,5 @@ 'GalleryApplicationVersionsOperations', 'GallerySharingProfileOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_galleries_operations.py index ec08c6fdc30e..85ddb32ccc50 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleriesOperations: - """GalleriesOperations async operations. - - You 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.compute.v2021_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.compute.v2021_10_01.aio.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Gallery] _json = self._serialize.body(gallery, 'GalleryUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -234,9 +253,9 @@ async def begin_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -259,37 +278,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -310,7 +339,7 @@ async def get( select: Optional[Union[str, "_models.SelectPermissions"]] = None, expand: Optional[Union[str, "_models.GalleryExpandParams"]] = None, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -326,13 +355,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_10_01.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -343,11 +375,13 @@ async def get( select=select, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -374,13 +408,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -389,11 +426,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -435,20 +474,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -458,8 +502,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -477,7 +527,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -488,13 +538,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_10_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +556,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -514,9 +569,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -553,7 +610,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -562,13 +619,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_10_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -576,9 +636,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -586,9 +648,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_application_versions_operations.py index 142985fe8fb1..cd7d2807fe3b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationVersionsOperations: - """GalleryApplicationVersionsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_10_01.aio.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -152,17 +156,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -171,20 +178,27 @@ async def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -203,17 +217,20 @@ async def _update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersionUpdate') @@ -227,11 +244,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -259,9 +278,9 @@ async def begin_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -295,17 +314,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -314,20 +336,27 @@ async def begin_update( 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('GalleryApplicationVersion', 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( @@ -349,7 +378,7 @@ async def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -370,13 +399,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -388,11 +420,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -421,13 +455,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -438,11 +475,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -493,22 +532,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -518,8 +562,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -539,7 +589,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationVersionList"]: + ) -> AsyncIterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -557,13 +607,16 @@ def list_by_gallery_application( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -574,9 +627,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -587,9 +642,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_applications_operations.py index 209945da7fe2..c3e90d0c6df0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationsOperations: - """GalleryApplicationsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_10_01.aio.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -144,17 +148,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -162,20 +169,27 @@ async def begin_create_or_update( 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('GalleryApplication', 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( @@ -193,17 +207,20 @@ async def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplicationUpdate') @@ -216,11 +233,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -277,17 +296,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -295,20 +317,27 @@ async def begin_update( 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('GalleryApplication', 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( @@ -328,7 +357,7 @@ async def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -344,13 +373,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_10_01.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -360,11 +392,13 @@ async def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,13 +426,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -408,11 +445,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,21 +497,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -482,8 +526,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -502,7 +552,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationList"]: + ) -> AsyncIterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -517,13 +567,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -533,9 +586,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -545,9 +600,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_image_versions_operations.py index bb3785483190..042fa06b1a30 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImageVersionsOperations: - """GalleryImageVersionsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_10_01.aio.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Create or update a gallery image version. :param resource_group_name: The name of the resource group. @@ -151,17 +155,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -170,20 +177,27 @@ async def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -202,17 +216,20 @@ async def _update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersionUpdate') @@ -226,11 +243,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -258,9 +277,9 @@ async def begin_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Update a gallery image version. :param resource_group_name: The name of the resource group. @@ -293,17 +312,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -312,20 +334,27 @@ async def begin_update( 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('GalleryImageVersion', 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( @@ -347,7 +376,7 @@ async def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery image version. :param resource_group_name: The name of the resource group. @@ -367,13 +396,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -385,11 +417,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -418,13 +452,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -435,11 +472,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -489,22 +528,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -514,8 +558,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -535,7 +585,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageVersionList"]: + ) -> AsyncIterable[_models.GalleryImageVersionList]: """List gallery image versions in a gallery image definition. :param resource_group_name: The name of the resource group. @@ -553,13 +603,16 @@ def list_by_gallery_image( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +623,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +638,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_images_operations.py index 699400bdfc85..b4f2588245ab 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImagesOperations: - """GalleryImagesOperations async operations. - - You 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.compute.v2021_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.compute.v2021_10_01.aio.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Create or update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -160,20 +167,27 @@ async def begin_create_or_update( 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('GalleryImage', 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( @@ -191,17 +205,20 @@ async def _update_initial( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImageUpdate') @@ -214,11 +231,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -245,9 +264,9 @@ async def begin_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -274,17 +293,20 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -292,20 +314,27 @@ async def begin_update( 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('GalleryImage', 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( @@ -325,7 +354,7 @@ async def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery image definition. :param resource_group_name: The name of the resource group. @@ -340,13 +369,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_10_01.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -356,11 +388,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -388,13 +422,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -404,11 +441,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -454,21 +493,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -478,8 +522,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -498,7 +548,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageList"]: + ) -> AsyncIterable[_models.GalleryImageList]: """List gallery image definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -512,13 +562,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_10_01.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -528,9 +581,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -540,9 +595,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_sharing_profile_operations.py index 2801ba1c0e16..1a2399bf187a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_sharing_profile_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_gallery_sharing_profile_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,42 +25,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GallerySharingProfileOperations: - """GallerySharingProfileOperations async operations. - - You 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.compute.v2021_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.compute.v2021_10_01.aio.ComputeManagementClient`'s + :attr:`gallery_sharing_profile` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _update_initial( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> "_models.SharingUpdate": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] + ) -> _models.SharingUpdate: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.SharingUpdate] _json = self._serialize.body(sharing_update, 'SharingUpdate') @@ -71,11 +73,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,9 +109,9 @@ async def begin_update( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.SharingUpdate"]: + ) -> AsyncLROPoller[_models.SharingUpdate]: """Update sharing profile of a gallery. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_10_01.models.SharingUpdate] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.SharingUpdate] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, sharing_update=sharing_update, 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('SharingUpdate', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/__init__.py index b74bafca71bc..bebd53c85e42 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/__init__.py @@ -88,7 +88,9 @@ SharingUpdateOperationTypes, StorageAccountType, ) - +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__ = [ 'ApiError', 'ApiErrorBase', @@ -169,3 +171,5 @@ 'SharingUpdateOperationTypes', 'StorageAccountType', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_compute_management_client_enums.py index 4e18b05290fc..92a74adfa50d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the aggregated replication status based on all the regional replication status flags. """ @@ -20,14 +19,14 @@ class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, En COMPLETED = "Completed" FAILED = "Failed" -class Architecture(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The architecture of the image. Applicable to OS disks only. """ X64 = "x64" ARM64 = "Arm64" -class ConfidentialVMEncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConfidentialVMEncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """confidential VM encryption types """ @@ -35,7 +34,7 @@ class ConfidentialVMEncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, ENCRYPTED_WITH_PMK = "EncryptedWithPmk" ENCRYPTED_WITH_CMK = "EncryptedWithCmk" -class GalleryApplicationVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryApplicationVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -46,18 +45,18 @@ class GalleryApplicationVersionPropertiesProvisioningState(with_metaclass(CaseIn DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryExpandParams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryExpandParams(str, Enum, metaclass=CaseInsensitiveEnumMeta): SHARING_PROFILE_GROUPS = "SharingProfile/Groups" -class GalleryExtendedLocationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryExtendedLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """It is type of the extended location. """ EDGE_ZONE = "EdgeZone" UNKNOWN = "Unknown" -class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImagePropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -68,7 +67,7 @@ class GalleryImagePropertiesProvisioningState(with_metaclass(CaseInsensitiveEnum DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryImageVersionPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -79,7 +78,7 @@ class GalleryImageVersionPropertiesProvisioningState(with_metaclass(CaseInsensit DELETING = "Deleting" MIGRATING = "Migrating" -class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -90,7 +89,7 @@ class GalleryPropertiesProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, DELETING = "Deleting" MIGRATING = "Migrating" -class GallerySharingPermissionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GallerySharingPermissionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the permission of sharing gallery. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Private** :code:`
`:code:`
` **Groups** """ @@ -98,7 +97,7 @@ class GallerySharingPermissionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, PRIVATE = "Private" GROUPS = "Groups" -class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite' """ @@ -106,14 +105,14 @@ class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows the user to specify whether the virtual machines created under this image are 'Generalized' or 'Specialized'. """ @@ -121,7 +120,7 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu GENERALIZED = "Generalized" SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux** @@ -130,7 +129,7 @@ class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WINDOWS = "Windows" LINUX = "Linux" -class ReplicationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Optional parameter which specifies the mode to be used for replication. This property is not updatable. """ @@ -138,7 +137,7 @@ class ReplicationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FULL = "Full" SHALLOW = "Shallow" -class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the regional replication state. """ @@ -147,15 +146,15 @@ class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAILED = "Failed" -class ReplicationStatusTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): REPLICATION_STATUS = "ReplicationStatus" -class SelectPermissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SelectPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): PERMISSIONS = "Permissions" -class SharingProfileGroupTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharingProfileGroupTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the type of sharing group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Subscriptions** :code:`
`:code:`
` **AADTenants** :code:`
`:code:`
` **Community** @@ -165,7 +164,7 @@ class SharingProfileGroupTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum AAD_TENANTS = "AADTenants" COMMUNITY = "Community" -class SharingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sharing state of the gallery, which only appears in the response. """ @@ -174,7 +173,7 @@ class SharingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" UNKNOWN = "Unknown" -class SharingUpdateOperationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharingUpdateOperationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the operation type of gallery sharing update. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset** @@ -185,7 +184,7 @@ class SharingUpdateOperationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E RESET = "Reset" ENABLE_COMMUNITY = "EnableCommunity" -class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type to be used to store the image. This property is not updatable. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_models_py3.py index 8e98684a4707..b72c3e504cfb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ApiError(msrest.serialization.Model): @@ -40,8 +42,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -280,8 +282,8 @@ class EncryptionImages(msrest.serialization.Model): def __init__( self, *, - os_disk_image: Optional["OSDiskImageEncryption"] = None, - data_disk_images: Optional[List["DataDiskImageEncryption"]] = None, + os_disk_image: Optional["_models.OSDiskImageEncryption"] = None, + data_disk_images: Optional[List["_models.DataDiskImageEncryption"]] = None, **kwargs ): """ @@ -373,8 +375,8 @@ class Gallery(Resource): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2021_10_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_10_01.models.GalleryPropertiesProvisioningState :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. @@ -414,9 +416,9 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, - sharing_profile: Optional["SharingProfile"] = None, - soft_delete_policy: Optional["SoftDeletePolicy"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, + sharing_profile: Optional["_models.SharingProfile"] = None, + soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, **kwargs ): """ @@ -475,8 +477,8 @@ class GalleryApplication(Resource): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes """ @@ -511,7 +513,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -533,8 +535,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes """ @@ -571,7 +573,7 @@ class GalleryApplicationList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplication"], + value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs ): @@ -660,8 +662,8 @@ class GalleryApplicationUpdate(UpdateResourceDefinition): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes """ @@ -693,7 +695,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -713,8 +715,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes """ @@ -747,8 +749,8 @@ class GalleryApplicationVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersionPropertiesProvisioningState :ivar replication_status: This is the replication status of the gallery image version. @@ -780,7 +782,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -822,7 +824,7 @@ class GalleryApplicationVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplicationVersion"], + value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs ): @@ -859,11 +861,11 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Possible values include: "Full", "Shallow". + This property is not updatable. Known values are: "Full", "Shallow". :vartype replication_mode: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationMode :ivar target_extended_locations: The target extended locations where the Image Version is going to be replicated to. This property is updatable. @@ -889,13 +891,13 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "ReplicationMode"]] = None, - target_extended_locations: Optional[List["GalleryTargetExtendedLocation"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, **kwargs ): """ @@ -913,12 +915,12 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Possible values include: "Full", "Shallow". + replication. This property is not updatable. Known values are: "Full", "Shallow". :paramtype replication_mode: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationMode :keyword target_extended_locations: The target extended locations where the Image Version is going to be replicated to. This property is updatable. @@ -959,11 +961,11 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Possible values include: "Full", "Shallow". + This property is not updatable. Known values are: "Full", "Shallow". :vartype replication_mode: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationMode :ivar target_extended_locations: The target extended locations where the Image Version is going to be replicated to. This property is updatable. @@ -999,15 +1001,15 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil def __init__( self, *, - source: "UserArtifactSource", - target_regions: Optional[List["TargetRegion"]] = None, + source: "_models.UserArtifactSource", + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "ReplicationMode"]] = None, - target_extended_locations: Optional[List["GalleryTargetExtendedLocation"]] = None, - manage_actions: Optional["UserArtifactManage"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, + manage_actions: Optional["_models.UserArtifactManage"] = None, enable_health_check: Optional[bool] = None, **kwargs ): @@ -1026,12 +1028,12 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Possible values include: "Full", "Shallow". + replication. This property is not updatable. Known values are: "Full", "Shallow". :paramtype replication_mode: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationMode :keyword target_extended_locations: The target extended locations where the Image Version is going to be replicated to. This property is updatable. @@ -1067,8 +1069,8 @@ class GalleryApplicationVersionUpdate(UpdateResourceDefinition): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersionPropertiesProvisioningState :ivar replication_status: This is the replication status of the gallery image version. @@ -1097,7 +1099,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -1133,7 +1135,7 @@ class GalleryArtifactSource(msrest.serialization.Model): def __init__( self, *, - managed_image: "ManagedArtifact", + managed_image: "_models.ManagedArtifact", **kwargs ): """ @@ -1188,7 +1190,7 @@ class GalleryDiskImage(msrest.serialization.Model): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2021_10_01.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource @@ -1207,13 +1209,13 @@ class GalleryDiskImage(msrest.serialization.Model): def __init__( self, *, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2021_10_01.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource @@ -1234,7 +1236,7 @@ class GalleryDataDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2021_10_01.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource @@ -1260,13 +1262,13 @@ def __init__( self, *, lun: int, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2021_10_01.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource @@ -1284,8 +1286,7 @@ class GalleryExtendedLocation(msrest.serialization.Model): :ivar name: :vartype name: str - :ivar type: It is type of the extended location. Possible values include: "EdgeZone", - "Unknown". + :ivar type: It is type of the extended location. Known values are: "EdgeZone", "Unknown". :vartype type: str or ~azure.mgmt.compute.v2021_10_01.models.GalleryExtendedLocationType """ @@ -1298,14 +1299,13 @@ def __init__( self, *, name: Optional[str] = None, - type: Optional[Union[str, "GalleryExtendedLocationType"]] = None, + type: Optional[Union[str, "_models.GalleryExtendedLocationType"]] = None, **kwargs ): """ :keyword name: :paramtype name: str - :keyword type: It is type of the extended location. Possible values include: "EdgeZone", - "Unknown". + :keyword type: It is type of the extended location. Known values are: "EdgeZone", "Unknown". :paramtype type: str or ~azure.mgmt.compute.v2021_10_01.models.GalleryExtendedLocationType """ super(GalleryExtendedLocation, self).__init__(**kwargs) @@ -1369,15 +1369,15 @@ class GalleryImage(Resource): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemStateTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_10_01.models.HyperVGeneration :ivar end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -1392,14 +1392,14 @@ class GalleryImage(Resource): :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2021_10_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_10_01.models.GalleryImagePropertiesProvisioningState :ivar features: A list of gallery image features. :vartype features: list[~azure.mgmt.compute.v2021_10_01.models.GalleryImageFeature] - :ivar architecture: The architecture of the image. Applicable to OS disks only. Possible values - include: "x64", "Arm64". + :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64", "Arm64". :vartype architecture: str or ~azure.mgmt.compute.v2021_10_01.models.Architecture """ @@ -1443,16 +1443,16 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, - features: Optional[List["GalleryImageFeature"]] = None, - architecture: Optional[Union[str, "Architecture"]] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, **kwargs ): """ @@ -1471,15 +1471,15 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemStateTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_10_01.models.HyperVGeneration :keyword end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -1496,8 +1496,8 @@ def __init__( :paramtype purchase_plan: ~azure.mgmt.compute.v2021_10_01.models.ImagePurchasePlan :keyword features: A list of gallery image features. :paramtype features: list[~azure.mgmt.compute.v2021_10_01.models.GalleryImageFeature] - :keyword architecture: The architecture of the image. Applicable to OS disks only. Possible - values include: "x64", "Arm64". + :keyword architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64", "Arm64". :paramtype architecture: str or ~azure.mgmt.compute.v2021_10_01.models.Architecture """ super(GalleryImage, self).__init__(location=location, tags=tags, **kwargs) @@ -1621,7 +1621,7 @@ class GalleryImageList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImage"], + value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs ): @@ -1661,15 +1661,15 @@ class GalleryImageUpdate(UpdateResourceDefinition): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemStateTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_10_01.models.HyperVGeneration :ivar end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -1684,14 +1684,14 @@ class GalleryImageUpdate(UpdateResourceDefinition): :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2021_10_01.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_10_01.models.GalleryImagePropertiesProvisioningState :ivar features: A list of gallery image features. :vartype features: list[~azure.mgmt.compute.v2021_10_01.models.GalleryImageFeature] - :ivar architecture: The architecture of the image. Applicable to OS disks only. Possible values - include: "x64", "Arm64". + :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64", "Arm64". :vartype architecture: str or ~azure.mgmt.compute.v2021_10_01.models.Architecture """ @@ -1732,16 +1732,16 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, - features: Optional[List["GalleryImageFeature"]] = None, - architecture: Optional[Union[str, "Architecture"]] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, **kwargs ): """ @@ -1758,15 +1758,15 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2021_10_01.models.OperatingSystemStateTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_10_01.models.HyperVGeneration :keyword end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -1783,8 +1783,8 @@ def __init__( :paramtype purchase_plan: ~azure.mgmt.compute.v2021_10_01.models.ImagePurchasePlan :keyword features: A list of gallery image features. :paramtype features: list[~azure.mgmt.compute.v2021_10_01.models.GalleryImageFeature] - :keyword architecture: The architecture of the image. Applicable to OS disks only. Possible - values include: "x64", "Arm64". + :keyword architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64", "Arm64". :paramtype architecture: str or ~azure.mgmt.compute.v2021_10_01.models.Architecture """ super(GalleryImageUpdate, self).__init__(tags=tags, **kwargs) @@ -1825,8 +1825,8 @@ class GalleryImageVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionPropertiesProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -1862,8 +1862,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["GalleryImageVersionStorageProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -1909,7 +1909,7 @@ class GalleryImageVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImageVersion"], + value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs ): @@ -1946,11 +1946,11 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Possible values include: "Full", "Shallow". + This property is not updatable. Known values are: "Full", "Shallow". :vartype replication_mode: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationMode :ivar target_extended_locations: The target extended locations where the Image Version is going to be replicated to. This property is updatable. @@ -1976,13 +1976,13 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "ReplicationMode"]] = None, - target_extended_locations: Optional[List["GalleryTargetExtendedLocation"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, **kwargs ): """ @@ -2000,12 +2000,12 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Possible values include: "Full", "Shallow". + replication. This property is not updatable. Known values are: "Full", "Shallow". :paramtype replication_mode: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationMode :keyword target_extended_locations: The target extended locations where the Image Version is going to be replicated to. This property is updatable. @@ -2035,9 +2035,9 @@ class GalleryImageVersionStorageProfile(msrest.serialization.Model): def __init__( self, *, - source: Optional["GalleryArtifactVersionSource"] = None, - os_disk_image: Optional["GalleryOSDiskImage"] = None, - data_disk_images: Optional[List["GalleryDataDiskImage"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, + os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, + data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, **kwargs ): """ @@ -2070,8 +2070,8 @@ class GalleryImageVersionUpdate(UpdateResourceDefinition): :ivar publishing_profile: The publishing profile of a gallery image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionPropertiesProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -2104,8 +2104,8 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["GalleryImageVersionStorageProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -2149,7 +2149,7 @@ class GalleryList(msrest.serialization.Model): def __init__( self, *, - value: List["Gallery"], + value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs ): @@ -2173,7 +2173,7 @@ class GalleryOSDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2021_10_01.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource @@ -2192,13 +2192,13 @@ class GalleryOSDiskImage(GalleryDiskImage): def __init__( self, *, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2021_10_01.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2021_10_01.models.GalleryArtifactVersionSource @@ -2217,7 +2217,7 @@ class GalleryTargetExtendedLocation(msrest.serialization.Model): created per extended location. This property is updatable. :vartype extended_location_replica_count: int :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS @@ -2237,10 +2237,10 @@ def __init__( self, *, name: Optional[str] = None, - extended_location: Optional["GalleryExtendedLocation"] = None, + extended_location: Optional["_models.GalleryExtendedLocation"] = None, extended_location_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - encryption: Optional["EncryptionImages"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + encryption: Optional["_models.EncryptionImages"] = None, **kwargs ): """ @@ -2252,7 +2252,7 @@ def __init__( created per extended location. This property is updatable. :paramtype extended_location_replica_count: int :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType @@ -2286,8 +2286,8 @@ class GalleryUpdate(UpdateResourceDefinition): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2021_10_01.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2021_10_01.models.GalleryPropertiesProvisioningState :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. @@ -2324,9 +2324,9 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, - sharing_profile: Optional["SharingProfile"] = None, - soft_delete_policy: Optional["SoftDeletePolicy"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, + sharing_profile: Optional["_models.SharingProfile"] = None, + soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, **kwargs ): """ @@ -2473,7 +2473,7 @@ def __init__( self, *, disk_encryption_set_id: Optional[str] = None, - security_profile: Optional["OSDiskImageSecurityProfile"] = None, + security_profile: Optional["_models.OSDiskImageSecurityProfile"] = None, **kwargs ): """ @@ -2490,8 +2490,8 @@ def __init__( class OSDiskImageSecurityProfile(msrest.serialization.Model): """Contains security profile for an OS disk image. - :ivar confidential_vm_encryption_type: confidential VM encryption types. Possible values - include: "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", "EncryptedWithCmk". + :ivar confidential_vm_encryption_type: confidential VM encryption types. Known values are: + "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", "EncryptedWithCmk". :vartype confidential_vm_encryption_type: str or ~azure.mgmt.compute.v2021_10_01.models.ConfidentialVMEncryptionType :ivar secure_vm_disk_encryption_set_id: secure VM disk encryption set id. @@ -2506,13 +2506,13 @@ class OSDiskImageSecurityProfile(msrest.serialization.Model): def __init__( self, *, - confidential_vm_encryption_type: Optional[Union[str, "ConfidentialVMEncryptionType"]] = None, + confidential_vm_encryption_type: Optional[Union[str, "_models.ConfidentialVMEncryptionType"]] = None, secure_vm_disk_encryption_set_id: Optional[str] = None, **kwargs ): """ - :keyword confidential_vm_encryption_type: confidential VM encryption types. Possible values - include: "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", "EncryptedWithCmk". + :keyword confidential_vm_encryption_type: confidential VM encryption types. Known values are: + "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", "EncryptedWithCmk". :paramtype confidential_vm_encryption_type: str or ~azure.mgmt.compute.v2021_10_01.models.ConfidentialVMEncryptionType :keyword secure_vm_disk_encryption_set_id: secure VM disk encryption set id. @@ -2540,8 +2540,8 @@ class RecommendedMachineConfiguration(msrest.serialization.Model): def __init__( self, *, - v_cp_us: Optional["ResourceRange"] = None, - memory: Optional["ResourceRange"] = None, + v_cp_us: Optional["_models.ResourceRange"] = None, + memory: Optional["_models.ResourceRange"] = None, **kwargs ): """ @@ -2562,7 +2562,7 @@ class RegionalReplicationStatus(msrest.serialization.Model): :ivar region: The region to which the gallery image version is being replicated to. :vartype region: str - :ivar state: This is the regional replication state. Possible values include: "Unknown", + :ivar state: This is the regional replication state. Known values are: "Unknown", "Replicating", "Completed", "Failed". :vartype state: str or ~azure.mgmt.compute.v2021_10_01.models.ReplicationState :ivar details: The details of the replication status. @@ -2605,7 +2605,7 @@ class RegionalSharingStatus(msrest.serialization.Model): :ivar region: Region name. :vartype region: str - :ivar state: Gallery sharing state in current region. Possible values include: "Succeeded", + :ivar state: Gallery sharing state in current region. Known values are: "Succeeded", "InProgress", "Failed", "Unknown". :vartype state: str or ~azure.mgmt.compute.v2021_10_01.models.SharingState :ivar details: Details of gallery regional sharing failure. @@ -2647,8 +2647,7 @@ class ReplicationStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Possible values include: "Unknown", "InProgress", "Completed", - "Failed". + replication status flags. Known values are: "Unknown", "InProgress", "Completed", "Failed". :vartype aggregated_state: str or ~azure.mgmt.compute.v2021_10_01.models.AggregatedReplicationState :ivar summary: This is a summary of replication status for each region. @@ -2715,7 +2714,7 @@ class SharingProfile(msrest.serialization.Model): :ivar permissions: This property allows you to specify the permission of sharing gallery. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Private** - :code:`
`:code:`
` **Groups**. Possible values include: "Private", "Groups". + :code:`
`:code:`
` **Groups**. Known values are: "Private", "Groups". :vartype permissions: str or ~azure.mgmt.compute.v2021_10_01.models.GallerySharingPermissionTypes :ivar groups: A list of sharing profile groups. @@ -2738,14 +2737,14 @@ class SharingProfile(msrest.serialization.Model): def __init__( self, *, - permissions: Optional[Union[str, "GallerySharingPermissionTypes"]] = None, + permissions: Optional[Union[str, "_models.GallerySharingPermissionTypes"]] = None, community_gallery_info: Optional[Any] = None, **kwargs ): """ :keyword permissions: This property allows you to specify the permission of sharing gallery. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Private** - :code:`
`:code:`
` **Groups**. Possible values include: "Private", "Groups". + :code:`
`:code:`
` **Groups**. Known values are: "Private", "Groups". :paramtype permissions: str or ~azure.mgmt.compute.v2021_10_01.models.GallerySharingPermissionTypes :keyword community_gallery_info: Information of community gallery if current gallery is shared @@ -2763,8 +2762,8 @@ class SharingProfileGroup(msrest.serialization.Model): :ivar type: This property allows you to specify the type of sharing group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Subscriptions** - :code:`
`:code:`
` **AADTenants** :code:`
`:code:`
` **Community**. Possible values - include: "Subscriptions", "AADTenants", "Community". + :code:`
`:code:`
` **AADTenants** :code:`
`:code:`
` **Community**. Known values + are: "Subscriptions", "AADTenants", "Community". :vartype type: str or ~azure.mgmt.compute.v2021_10_01.models.SharingProfileGroupTypes :ivar ids: A list of subscription/tenant ids the gallery is aimed to be shared to. :vartype ids: list[str] @@ -2778,15 +2777,15 @@ class SharingProfileGroup(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "SharingProfileGroupTypes"]] = None, + type: Optional[Union[str, "_models.SharingProfileGroupTypes"]] = None, ids: Optional[List[str]] = None, **kwargs ): """ :keyword type: This property allows you to specify the type of sharing group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Subscriptions** - :code:`
`:code:`
` **AADTenants** :code:`
`:code:`
` **Community**. Possible values - include: "Subscriptions", "AADTenants", "Community". + :code:`
`:code:`
` **AADTenants** :code:`
`:code:`
` **Community**. Known values + are: "Subscriptions", "AADTenants", "Community". :paramtype type: str or ~azure.mgmt.compute.v2021_10_01.models.SharingProfileGroupTypes :keyword ids: A list of subscription/tenant ids the gallery is aimed to be shared to. :paramtype ids: list[str] @@ -2801,7 +2800,7 @@ class SharingStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar aggregated_state: Aggregated sharing state of current gallery. Possible values include: + :ivar aggregated_state: Aggregated sharing state of current gallery. Known values are: "Succeeded", "InProgress", "Failed", "Unknown". :vartype aggregated_state: str or ~azure.mgmt.compute.v2021_10_01.models.SharingState :ivar summary: Summary of all regional sharing status. @@ -2820,7 +2819,7 @@ class SharingStatus(msrest.serialization.Model): def __init__( self, *, - summary: Optional[List["RegionalSharingStatus"]] = None, + summary: Optional[List["_models.RegionalSharingStatus"]] = None, **kwargs ): """ @@ -2839,8 +2838,8 @@ class SharingUpdate(msrest.serialization.Model): :ivar operation_type: Required. This property allows you to specify the operation type of gallery sharing update. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` - **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Possible values - include: "Add", "Remove", "Reset", "EnableCommunity". + **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Known values + are: "Add", "Remove", "Reset", "EnableCommunity". :vartype operation_type: str or ~azure.mgmt.compute.v2021_10_01.models.SharingUpdateOperationTypes :ivar groups: A list of sharing profile groups. @@ -2859,15 +2858,15 @@ class SharingUpdate(msrest.serialization.Model): def __init__( self, *, - operation_type: Union[str, "SharingUpdateOperationTypes"], - groups: Optional[List["SharingProfileGroup"]] = None, + operation_type: Union[str, "_models.SharingUpdateOperationTypes"], + groups: Optional[List["_models.SharingProfileGroup"]] = None, **kwargs ): """ :keyword operation_type: Required. This property allows you to specify the operation type of gallery sharing update. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` - **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Possible values - include: "Add", "Remove", "Reset", "EnableCommunity". + **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Known values + are: "Add", "Remove", "Reset", "EnableCommunity". :paramtype operation_type: str or ~azure.mgmt.compute.v2021_10_01.models.SharingUpdateOperationTypes :keyword groups: A list of sharing profile groups. @@ -2916,7 +2915,7 @@ class TargetRegion(msrest.serialization.Model): region. This property is updatable. :vartype regional_replica_count: int :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS @@ -2940,8 +2939,8 @@ def __init__( *, name: str, regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - encryption: Optional["EncryptionImages"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + encryption: Optional["_models.EncryptionImages"] = None, **kwargs ): """ @@ -2951,7 +2950,7 @@ def __init__( region. This property is updatable. :paramtype regional_replica_count: int :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_10_01.models.StorageAccountType diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/__init__.py index 8e08b35d1064..7e5da4070f2b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/__init__.py @@ -13,6 +13,9 @@ from ._gallery_application_versions_operations import GalleryApplicationVersionsOperations from ._gallery_sharing_profile_operations import GallerySharingProfileOperations +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__ = [ 'GalleriesOperations', 'GalleryImagesOperations', @@ -21,3 +24,5 @@ 'GalleryApplicationVersionsOperations', 'GallerySharingProfileOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_galleries_operations.py index 500d84ece9e4..a4b2968cc4a5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.Gallery] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,9 +128,12 @@ def build_get_request( expand: Optional[Union[str, "_models.GalleryExpandParams"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -140,22 +145,20 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, '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, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -180,18 +186,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +205,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries") # pylint: disable=line-too-long path_format_arguments = { @@ -214,18 +221,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -234,9 +239,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") path_format_arguments = { @@ -246,58 +254,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleriesOperations(object): - """GalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_10_01.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -309,11 +316,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -346,9 +355,9 @@ def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -370,37 +379,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -417,17 +436,20 @@ def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Gallery] _json = self._serialize.body(gallery, 'GalleryUpdate') @@ -439,11 +461,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -469,9 +493,9 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -493,37 +517,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -544,7 +578,7 @@ def get( select: Optional[Union[str, "_models.SelectPermissions"]] = None, expand: Optional[Union[str, "_models.GalleryExpandParams"]] = None, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -560,13 +594,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_10_01.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -577,11 +614,13 @@ def get( select=select, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -608,13 +647,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -623,11 +665,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -669,20 +713,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -692,8 +741,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -711,7 +766,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -721,13 +776,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_10_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -736,9 +794,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -747,9 +807,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -786,7 +848,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -794,13 +856,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_10_01.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -808,9 +873,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -818,9 +885,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_application_versions_operations.py index 5438a74a10e7..02532d96d9f1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +137,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +156,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -177,9 +180,12 @@ def build_delete_request_initial( gallery_application_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +199,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -216,9 +220,12 @@ def build_list_by_gallery_application_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -231,42 +238,38 @@ def build_list_by_gallery_application_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationVersionsOperations(object): - """GalleryApplicationVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_10_01.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -274,17 +277,20 @@ def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -298,11 +304,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -373,17 +381,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -392,20 +403,27 @@ def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -424,17 +442,20 @@ def _update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersionUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,9 +503,9 @@ def begin_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -516,17 +539,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -535,20 +561,27 @@ def begin_update( 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('GalleryApplicationVersion', 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( @@ -570,7 +603,7 @@ def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -591,13 +624,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -609,11 +645,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -642,13 +680,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -659,11 +700,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -714,22 +757,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -739,8 +787,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -760,7 +814,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationVersionList"]: + ) -> Iterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -778,13 +832,16 @@ def list_by_gallery_application( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +852,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -808,9 +867,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_applications_operations.py index f0b5ae70279a..ddfd5c16a838 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplication] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_get_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -181,18 +187,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +207,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications") # pylint: disable=line-too-long path_format_arguments = { @@ -217,59 +224,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationsOperations(object): - """GalleryApplicationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_10_01.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -282,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -320,9 +328,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -351,17 +359,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -369,20 +380,27 @@ def begin_create_or_update( 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('GalleryApplication', 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( @@ -400,17 +418,20 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplicationUpdate') @@ -423,11 +444,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -454,9 +477,9 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -484,17 +507,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -502,20 +528,27 @@ def begin_update( 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('GalleryApplication', 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( @@ -535,7 +568,7 @@ def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -551,13 +584,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_10_01.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -567,11 +603,13 @@ def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -599,13 +637,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -615,11 +656,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -665,21 +708,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -689,8 +737,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -709,7 +763,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationList"]: + ) -> Iterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -724,13 +778,16 @@ def list_by_gallery( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_10_01.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -740,9 +797,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -752,9 +811,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_image_versions_operations.py index 522f76fc9f94..f5df8b915754 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +137,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +156,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -177,9 +180,12 @@ def build_delete_request_initial( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +199,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -216,9 +220,12 @@ def build_list_by_gallery_image_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -231,42 +238,38 @@ def build_list_by_gallery_image_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImageVersionsOperations(object): - """GalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_10_01.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -274,17 +277,20 @@ def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -298,11 +304,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Create or update a gallery image version. :param resource_group_name: The name of the resource group. @@ -372,17 +380,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -423,17 +441,20 @@ def _update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersionUpdate') @@ -447,11 +468,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -479,9 +502,9 @@ def begin_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Update a gallery image version. :param resource_group_name: The name of the resource group. @@ -514,17 +537,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -533,20 +559,27 @@ def begin_update( 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('GalleryImageVersion', 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( @@ -568,7 +601,7 @@ def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery image version. :param resource_group_name: The name of the resource group. @@ -588,13 +621,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -606,11 +642,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -639,13 +677,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -656,11 +697,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -710,22 +753,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -735,8 +783,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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,7 +810,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageVersionList"]: + ) -> Iterable[_models.GalleryImageVersionList]: """List gallery image versions in a gallery image definition. :param resource_group_name: The name of the resource group. @@ -774,13 +828,16 @@ def list_by_gallery_image( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_10_01.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -791,9 +848,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -804,9 +863,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_images_operations.py index 7bd17bf8322d..228158dc4a03 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImage] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -181,18 +187,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +207,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images") # pylint: disable=line-too-long path_format_arguments = { @@ -217,59 +224,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImagesOperations(object): - """GalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_10_01.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -282,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -320,9 +328,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Create or update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -349,17 +357,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -367,20 +378,27 @@ def begin_create_or_update( 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('GalleryImage', 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( @@ -398,17 +416,20 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImageUpdate') @@ -421,11 +442,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +475,9 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -481,17 +504,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -499,20 +525,27 @@ def begin_update( 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('GalleryImage', 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( @@ -532,7 +565,7 @@ def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery image definition. :param resource_group_name: The name of the resource group. @@ -547,13 +580,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_10_01.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -563,11 +599,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,13 +633,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -611,11 +652,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -661,21 +704,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-10-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +733,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +759,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageList"]: + ) -> Iterable[_models.GalleryImageList]: """List gallery image definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -718,13 +772,16 @@ def list_by_gallery( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_10_01.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -734,9 +791,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -746,9 +805,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_sharing_profile_operations.py index 2651656632c0..b38fb818a489 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_sharing_profile_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_gallery_sharing_profile_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +33,17 @@ def build_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.SharingUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share") # pylint: disable=line-too-long path_format_arguments = { @@ -52,62 +55,61 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class GallerySharingProfileOperations(object): - """GallerySharingProfileOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GallerySharingProfileOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_10_01.ComputeManagementClient`'s + :attr:`gallery_sharing_profile` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _update_initial( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> "_models.SharingUpdate": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] + ) -> _models.SharingUpdate: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.SharingUpdate] _json = self._serialize.body(sharing_update, 'SharingUpdate') @@ -119,11 +121,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -153,9 +157,9 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> LROPoller["_models.SharingUpdate"]: + ) -> LROPoller[_models.SharingUpdate]: """Update sharing profile of a gallery. :param resource_group_name: The name of the resource group. @@ -177,37 +181,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_10_01.models.SharingUpdate] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-10-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.SharingUpdate] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, sharing_update=sharing_update, 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('SharingUpdate', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_10_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/_compute_management_client.py index eb54ebcfdfb8..4027a580dfef 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/_compute_management_client.py @@ -127,32 +127,84 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_point_collections = RestorePointCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservation_groups = CapacityReservationGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservations = CapacityReservationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_point_collections = RestorePointCollectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_points = RestorePointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservations = CapacityReservationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/_compute_management_client.py index 3b9669865f72..9ef3af9b307d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/_compute_management_client.py @@ -129,32 +129,84 @@ 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.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_point_collections = RestorePointCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservation_groups = CapacityReservationGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservations = CapacityReservationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_point_collections = RestorePointCollectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_points = RestorePointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservations = CapacityReservationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/__init__.py index 8779b7a16206..e52069811132 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/__init__.py @@ -33,6 +33,9 @@ from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations from ._virtual_machine_scale_set_vm_run_commands_operations import VirtualMachineScaleSetVMRunCommandsOperations +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', 'AvailabilitySetsOperations', @@ -61,3 +64,5 @@ 'VirtualMachineRunCommandsOperations', 'VirtualMachineScaleSetVMRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_availability_sets_operations.py index 50f3c110139e..15c5c40eddf5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_capacity_reservation_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_capacity_reservation_groups_operations.py index 3c0d79efd771..2eabc337da2f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_capacity_reservation_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_capacity_reservation_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CapacityReservationGroupsOperations: - """CapacityReservationGroupsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroup", + parameters: _models.CapacityReservationGroup, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details. @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroupUpdate", + parameters: _models.CapacityReservationGroupUpdate, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. @@ -138,14 +142,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroupUpdate') @@ -157,11 +164,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -203,13 +212,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -218,11 +230,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,7 +260,7 @@ async def get( capacity_reservation_group_name: str, expand: Optional[Union[str, "_models.CapacityReservationGroupInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation that retrieves information about a capacity reservation group. :param resource_group_name: The name of the resource group. @@ -264,13 +278,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] request = build_get_request( @@ -280,11 +297,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationGroupListResult"]: + ) -> AsyncIterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -329,13 +348,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -345,9 +367,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, 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: @@ -357,9 +381,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 +423,7 @@ def list_by_subscription( self, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationGroupListResult"]: + ) -> AsyncIterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -413,13 +439,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -428,9 +457,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -439,9 +470,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_capacity_reservations_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_capacity_reservations_operations.py index 236edabaed57..492f089e57ba 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_capacity_reservations_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_capacity_reservations_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CapacityReservationsOperations: - """CapacityReservationsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`capacity_reservations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> "_models.CapacityReservation": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] + ) -> _models.CapacityReservation: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] _json = self._serialize.body(parameters, 'CapacityReservation') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> AsyncLROPoller["_models.CapacityReservation"]: + ) -> AsyncLROPoller[_models.CapacityReservation]: """The operation to create or update a capacity reservation. Please note some properties can be set only during capacity reservation creation. Please refer to https://aka.ms/CapacityReservation for more details. @@ -139,17 +143,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -157,20 +164,27 @@ async def begin_create_or_update( 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('CapacityReservation', 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( @@ -188,17 +202,20 @@ async def _update_initial( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> Optional["_models.CapacityReservation"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CapacityReservation"]] + ) -> Optional[_models.CapacityReservation]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.CapacityReservation]] _json = self._serialize.body(parameters, 'CapacityReservationUpdate') @@ -211,11 +228,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -244,9 +263,9 @@ async def begin_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.CapacityReservation"]: + ) -> AsyncLROPoller[_models.CapacityReservation]: """The operation to update a capacity reservation. :param resource_group_name: The name of the resource group. @@ -271,17 +290,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -289,20 +311,27 @@ async def begin_update( 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('CapacityReservation', 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( @@ -322,13 +351,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements capacity_reservation_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -338,11 +370,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -389,21 +423,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -413,8 +452,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -435,7 +480,7 @@ async def get( capacity_reservation_name: str, expand: Optional[Union[str, "_models.CapacityReservationInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservation": + ) -> _models.CapacityReservation: """The operation that retrieves information about the capacity reservation. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.CapacityReservation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list_by_capacity_reservation_group( resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationListResult"]: + ) -> AsyncIterable[_models.CapacityReservationListResult]: """Lists all of the capacity reservations in the specified capacity reservation group. Use the nextLink property in the response to get the next page of capacity reservations. @@ -517,13 +567,16 @@ def list_by_capacity_reservation_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.CapacityReservationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -533,9 +586,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_capacity_reservation_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: @@ -545,9 +600,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_dedicated_host_groups_operations.py index 09ab190bcd21..8a8925b61178 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_dedicated_host_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostGroupsOperations: - """DedicatedHostGroupsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -137,14 +141,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -156,11 +163,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -199,13 +208,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,11 +226,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +256,7 @@ async def get( host_group_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -258,13 +272,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -274,11 +291,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +323,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -317,13 +336,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -332,9 +354,11 @@ def prepare_request(next_link=None): 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: @@ -343,9 +367,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -382,7 +408,7 @@ async def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -393,13 +419,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -407,9 +436,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -417,9 +448,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_dedicated_hosts_operations.py index d5d806c2013f..8b8d035b2c6a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostsOperations: - """DedicatedHostsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('DedicatedHost', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -267,17 +286,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -285,20 +307,27 @@ async def begin_update( 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('DedicatedHost', 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( @@ -318,13 +347,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -334,11 +366,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,21 +417,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -407,8 +446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -429,7 +474,7 @@ async def get( host_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -495,7 +545,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostListResult"]: + ) -> AsyncIterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -510,13 +560,16 @@ def list_by_host_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -526,9 +579,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -538,9 +593,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -580,13 +637,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -596,11 +656,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -649,21 +711,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -673,8 +740,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_images_operations.py index d43a90985e0a..cddf5bded3ed 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_log_analytics_operations.py index a1ffabdc1d48..bb0bc7362bf9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_operations.py index 6bd3991e0d31..f22189cf7218 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_proximity_placement_groups_operations.py index aa2a9a66354c..d6095561b6d5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,7 +254,7 @@ async def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -255,13 +269,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -271,11 +288,13 @@ async def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -300,7 +319,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -310,13 +329,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -324,9 +346,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -334,9 +358,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -374,7 +400,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -386,13 +412,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,9 +430,11 @@ def prepare_request(next_link=None): 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: @@ -412,9 +443,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_restore_point_collections_operations.py index 80fafbfb7d22..e1d7590871f0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_restore_point_collections_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_restore_point_collections_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,35 +27,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RestorePointCollectionsOperations: - """RestorePointCollectionsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollection", + parameters: _models.RestorePointCollection, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. @@ -71,14 +70,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollection') @@ -90,11 +92,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,9 +128,9 @@ async def update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollectionUpdate", + parameters: _models.RestorePointCollectionUpdate, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. @@ -140,14 +144,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollectionUpdate') @@ -159,11 +166,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -190,13 +199,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -205,11 +217,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_name=restore_point_collection_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -252,20 +266,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -275,8 +294,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -296,7 +321,7 @@ async def get( restore_point_collection_name: str, expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to get the restore point collection. :param resource_group_name: The name of the resource group. @@ -311,13 +336,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] request = build_get_request( @@ -327,11 +355,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -357,7 +387,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.RestorePointCollectionListResult"]: + ) -> AsyncIterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in a resource group. :param resource_group_name: The name of the resource group. @@ -369,13 +399,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -384,9 +417,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -395,9 +430,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -434,7 +471,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.RestorePointCollectionListResult"]: + ) -> AsyncIterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in the subscription. Use nextLink property in the response to get the next page of restore point collections. Do this till nextLink is not null to fetch all the restore point collections. @@ -446,13 +483,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -460,9 +500,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -470,9 +512,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_restore_points_operations.py index 1f2d8734a150..d82d93a96cc4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_restore_points_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_restore_points_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RestorePointsOperations: - """RestorePointsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`restore_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_initial( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> "_models.RestorePoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] + ) -> _models.RestorePoint: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] _json = self._serialize.body(parameters, 'RestorePoint') @@ -73,11 +75,13 @@ async def _create_initial( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -104,9 +108,9 @@ async def begin_create( resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> AsyncLROPoller["_models.RestorePoint"]: + ) -> AsyncLROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. @@ -131,17 +135,20 @@ async def begin_create( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.RestorePoint] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] 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, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, @@ -149,20 +156,27 @@ async def begin_create( 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('RestorePoint', 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( @@ -182,13 +196,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -198,11 +215,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_name=restore_point_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,21 +266,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -271,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -293,7 +323,7 @@ async def get( restore_point_name: str, expand: Optional[Union[str, "_models.RestorePointExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePoint": + ) -> _models.RestorePoint: """The operation to get the restore point. :param resource_group_name: The name of the resource group. @@ -310,13 +340,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] request = build_get_request( @@ -327,11 +360,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_ssh_public_keys_operations.py index 1a54ea8a7900..86066bab9e5c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_ssh_public_keys_operations.py @@ -15,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 @@ -24,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SshPublicKeysOperations: - """SshPublicKeysOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -60,13 +59,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -74,9 +76,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -84,9 +88,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +130,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -137,13 +143,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -152,9 +161,11 @@ def prepare_request(next_link=None): 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: @@ -163,9 +174,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -203,9 +216,9 @@ async def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -219,14 +232,17 @@ async def create( :rtype: ~azure.mgmt.compute.v2021_11_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -238,11 +254,13 @@ async def create( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -272,9 +290,9 @@ async def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -288,14 +306,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -307,11 +328,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -350,13 +373,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -365,11 +391,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,7 +420,7 @@ async def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -404,13 +432,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -419,11 +450,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,7 +483,7 @@ async def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -464,13 +497,16 @@ async def generate_key_pair( :rtype: ~azure.mgmt.compute.v2021_11_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -479,11 +515,13 @@ async def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_usage_operations.py index 20292e54c926..fdea7b4db055 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_extension_images_operations.py index 72d50f5bd8e1..f40a42429c4c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_extensions_operations.py index f80814588fbe..27ae427de150 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_images_edge_zone_operations.py index 78c1cc6a2ac6..3ce59d46bb0e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_images_edge_zone_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesEdgeZoneOperations: - """VirtualMachineImagesEdgeZoneOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +52,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. @@ -73,13 +72,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -92,11 +94,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -129,7 +133,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. @@ -156,13 +160,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -177,11 +184,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -209,7 +218,7 @@ async def list_offers( edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. @@ -224,13 +233,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -240,11 +252,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -271,7 +285,7 @@ async def list_publishers( location: str, edge_zone: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. @@ -283,13 +297,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -298,11 +315,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -331,7 +350,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. @@ -348,13 +367,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -365,11 +387,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_images_operations.py index 13dc61164084..cb0b4d88d4bd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_run_commands_operations.py index 856d496d8311..b4b3c11cd01f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -64,13 +63,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,7 +137,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -143,13 +149,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -158,11 +167,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,18 +199,21 @@ async def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -212,11 +226,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,11 +263,11 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -263,7 +279,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -280,16 +296,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -297,20 +316,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -328,18 +354,21 @@ async def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -352,11 +381,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,11 +414,11 @@ async def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -398,7 +429,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -415,16 +446,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -432,20 +466,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -465,13 +506,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -481,11 +525,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,21 +576,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -554,8 +605,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -576,7 +633,7 @@ async def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -592,13 +649,16 @@ async def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -609,11 +669,13 @@ async def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -641,7 +703,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -657,13 +719,16 @@ def list_by_virtual_machine( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -674,9 +739,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -687,9 +754,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index e428de269c37..e6ec64bdcfe7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -189,17 +203,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -212,11 +229,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -276,17 +295,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -294,20 +316,27 @@ async def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -327,13 +356,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -343,11 +375,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,21 +426,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -416,8 +455,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -438,7 +483,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -516,13 +566,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -532,9 +585,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -544,9 +599,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index e67499231789..f005ae9d29a9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,13 +292,16 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu vm_scale_set_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -276,11 +310,13 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,20 +360,25 @@ async def begin_start_extension_upgrade( # pylint: disable=inconsistent-return- :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_extension_upgrade_initial( + raw_result = await self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -347,8 +388,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -367,7 +414,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -379,13 +426,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -394,11 +444,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py index 6eeab40b6783..d50352fc7bda 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMExtensionsOperations: - """VirtualMachineScaleSetVMExtensionsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -51,17 +50,20 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -111,9 +115,9 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -161,20 +168,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -193,17 +207,20 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -217,11 +234,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -249,9 +268,9 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -280,17 +299,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -299,20 +321,27 @@ async def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -333,13 +362,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -350,11 +382,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -402,22 +436,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -427,8 +466,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -450,7 +495,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -468,13 +513,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -486,11 +534,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -519,7 +569,7 @@ async def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -535,13 +585,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -552,11 +605,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index 3d2a1e0e8b64..07ff443ea2f0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMRunCommandsOperations: - """VirtualMachineScaleSetVMRunCommandsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,18 +52,21 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -78,11 +80,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -114,11 +118,11 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -131,7 +135,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -148,16 +152,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -166,20 +173,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -198,18 +212,21 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -223,11 +240,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,11 +274,11 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -272,7 +291,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -289,16 +308,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -307,20 +329,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -341,13 +370,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -358,11 +390,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -410,22 +444,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -435,8 +474,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -458,7 +503,7 @@ async def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -476,13 +521,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_request( @@ -494,11 +542,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +577,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -545,13 +595,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -563,9 +616,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -577,9 +632,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index 60cf568fa9e7..180e1b7bc4b3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -78,11 +80,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -132,17 +136,20 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -150,6 +157,8 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,13 +195,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -196,11 +214,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,21 +266,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -270,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -291,13 +322,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -307,11 +341,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,21 +394,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -382,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -401,17 +448,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -424,11 +474,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,9 +511,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -487,17 +539,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -505,20 +560,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -539,13 +601,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -556,11 +621,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -609,22 +676,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -634,8 +706,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -656,7 +734,7 @@ async def get( instance_id: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -674,13 +752,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -691,11 +772,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -723,7 +806,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -737,13 +820,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -753,11 +839,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -787,7 +875,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -811,13 +899,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -830,9 +921,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -845,9 +938,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -888,13 +983,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -905,11 +1003,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -961,22 +1061,27 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -986,8 +1091,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1007,13 +1118,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1023,11 +1137,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1072,21 +1188,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1096,8 +1217,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1117,13 +1244,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1133,11 +1263,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1182,21 +1314,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1206,8 +1343,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1227,13 +1370,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1243,11 +1389,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1293,21 +1441,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1317,8 +1470,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1339,7 +1498,7 @@ async def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -1358,13 +1517,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1375,11 +1537,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1407,13 +1571,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1423,11 +1590,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1472,21 +1641,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1496,8 +1670,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1531,13 +1711,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -1547,11 +1730,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1573,18 +1758,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1597,11 +1785,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1630,11 +1820,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1645,7 +1835,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_11_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1662,16 +1852,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1679,20 +1872,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_sets_operations.py index 0f9a682f667c..824e0fada385 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -151,11 +160,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -185,9 +196,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -210,37 +221,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -257,17 +278,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -279,11 +303,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +335,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -334,37 +360,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -384,13 +420,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -400,11 +439,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,21 +491,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -474,8 +520,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -495,7 +547,7 @@ async def get( vm_scale_set_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -511,13 +563,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -527,11 +582,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -556,17 +613,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -581,11 +641,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -607,7 +669,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -634,23 +696,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -660,8 +727,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -678,18 +751,21 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -702,11 +778,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat json=_json, force_deletion=force_deletion, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -728,7 +806,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: @@ -756,17 +834,20 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, @@ -774,6 +855,8 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -783,8 +866,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -803,7 +892,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -815,13 +904,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -830,11 +922,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -860,7 +954,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -872,13 +966,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -887,9 +984,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -898,9 +997,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -937,7 +1038,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -949,13 +1050,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -963,9 +1067,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -973,9 +1079,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1014,7 +1122,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1029,13 +1137,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1045,9 +1156,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1057,9 +1170,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1098,7 +1213,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1112,13 +1227,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1128,9 +1246,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1140,9 +1260,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1180,17 +1302,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1206,11 +1331,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1233,7 +1360,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1264,17 +1391,20 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -1282,6 +1412,8 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1291,8 +1423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1309,17 +1447,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1334,11 +1475,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1360,7 +1503,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1385,23 +1528,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1411,8 +1559,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1429,17 +1583,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1454,11 +1611,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1480,7 +1639,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1505,23 +1664,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1531,8 +1695,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1549,17 +1719,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1574,11 +1747,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1600,7 +1775,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1626,23 +1801,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1652,8 +1832,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1670,17 +1856,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1695,11 +1884,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1721,7 +1912,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1749,23 +1940,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1775,8 +1971,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1793,17 +1995,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1815,11 +2020,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1841,7 +2048,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1865,23 +2072,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1891,8 +2103,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1909,17 +2127,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -1934,11 +2155,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1960,7 +2183,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -1986,23 +2209,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2012,8 +2240,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2030,17 +2264,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2055,11 +2292,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2081,7 +2320,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2107,23 +2346,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2133,8 +2377,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2156,7 +2406,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( zone: Optional[str] = None, placement_group_id: Optional[str] = None, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2178,13 +2428,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2196,11 +2449,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( zone=zone, placement_group_id=placement_group_id, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2226,7 +2481,7 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -2243,14 +2498,17 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret :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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -2262,11 +2520,13 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2287,17 +2547,20 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'OrchestrationServiceStateInput') @@ -2309,11 +2572,13 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2335,7 +2600,7 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> AsyncLROPoller[None]: """Changes ServiceState property for a given service. @@ -2358,23 +2623,28 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._set_orchestration_service_state_initial( + raw_result = await self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -2384,8 +2654,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_sizes_operations.py index 3abad7e8984d..f06415dae373 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machines_operations.py index fac2d874fd07..c6e9060a19a0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2021_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.compute.v2021_11_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -338,37 +364,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -385,17 +421,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -407,11 +446,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -437,9 +478,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -462,37 +503,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -512,13 +563,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -528,11 +582,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -578,21 +634,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -602,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -623,7 +690,7 @@ async def get( vm_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. @@ -641,13 +708,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -657,11 +727,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -688,7 +760,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -700,13 +772,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -715,11 +790,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -746,13 +823,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -761,11 +841,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -808,20 +890,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -831,8 +918,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -852,13 +945,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements hibernate: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -868,11 +964,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, hibernate=hibernate, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -919,21 +1017,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, hibernate=hibernate, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -943,8 +1046,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -980,13 +1089,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -995,11 +1107,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1022,7 +1136,7 @@ def list( resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1040,13 +1154,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1056,9 +1173,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -1068,9 +1187,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -1109,7 +1230,7 @@ def list_all( status_only: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1128,13 +1249,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1144,9 +1268,11 @@ def prepare_request(next_link=None): status_only=status_only, filter=filter, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1156,9 +1282,11 @@ def prepare_request(next_link=None): status_only=status_only, 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 @@ -1197,7 +1325,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1212,13 +1340,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1228,9 +1359,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1240,9 +1373,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1282,13 +1417,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1298,11 +1436,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1350,21 +1490,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1374,8 +1519,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1394,13 +1545,16 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -1409,11 +1563,13 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1455,20 +1611,25 @@ async def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reapply_initial( + raw_result = await self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1478,8 +1639,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1498,13 +1665,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1513,11 +1683,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1559,20 +1731,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1582,8 +1759,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1602,13 +1785,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1617,11 +1803,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1663,20 +1851,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1686,8 +1879,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1706,13 +1905,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1721,11 +1923,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1767,20 +1971,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1790,8 +1999,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1808,17 +2023,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -1833,11 +2051,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1859,7 +2079,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -1883,23 +2103,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -1909,8 +2134,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1930,7 +2161,7 @@ async def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -1946,13 +2177,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1962,11 +2196,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1993,13 +2229,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2008,11 +2247,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2054,20 +2295,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2077,8 +2323,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2109,13 +2361,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2124,11 +2379,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2150,14 +2407,17 @@ async def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -2166,11 +2426,13 @@ async def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2199,7 +2461,7 @@ async def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -2220,34 +2482,44 @@ async def begin_assess_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = await self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -2264,17 +2536,20 @@ async def _install_patches_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineInstallPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineInstallPatchesResult"]] + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineInstallPatchesResult]] _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') @@ -2286,11 +2561,13 @@ async def _install_patches_initial( content_type=content_type, json=_json, template_url=self._install_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2318,9 +2595,9 @@ async def begin_install_patches( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineInstallPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. @@ -2344,37 +2621,47 @@ async def begin_install_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineInstallPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstallPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstallPatchesResult"] 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._install_patches_initial( + raw_result = await self._install_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineInstallPatchesResult', 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( @@ -2391,18 +2678,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2414,11 +2704,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2446,11 +2738,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2459,7 +2751,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_11_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2476,36 +2768,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_11_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/__init__.py index ddefdfeddb5a..058f60da6639 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/__init__.py @@ -321,7 +321,9 @@ WindowsPatchAssessmentMode, WindowsVMGuestPatchMode, ) - +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__ = [ 'AdditionalCapabilities', 'AdditionalUnattendContent', @@ -635,3 +637,5 @@ 'WindowsPatchAssessmentMode', 'WindowsVMGuestPatchMode', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/_compute_management_client_enums.py index 2c98ae0d7296..261ab45b887b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/_compute_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ArchitectureTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ArchitectureTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the Architecture Type """ X64 = "x64" ARM64 = "Arm64" -class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. """ @@ -26,7 +25,7 @@ class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CLASSIC = "Classic" ALIGNED = "Aligned" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -37,15 +36,15 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class CapacityReservationGroupInstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CapacityReservationGroupInstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" -class CapacityReservationInstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CapacityReservationInstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" -class ConsistencyModeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConsistencyModeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the consistency mode for the restore point. Please refer to https://aka.ms/RestorePoints for more details. """ @@ -54,7 +53,7 @@ class ConsistencyModeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_SYSTEM_CONSISTENT = "FileSystemConsistent" APPLICATION_CONSISTENT = "ApplicationConsistent" -class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the software license type that will be applied to the VMs deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` @@ -65,20 +64,20 @@ class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" -class DeleteOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DeleteOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify what happens to the network interface when the VM is deleted """ DELETE = "Delete" DETACH = "Detach" -class DiffDiskOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk option for operating system disk. """ LOCAL = "Local" -class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskPlacement(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk placement for operating system disk. This property can be used by user in the request to choose the location i.e, cache disk or resource disk space for Ephemeral OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer @@ -91,7 +90,7 @@ class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CACHE_DISK = "CacheDisk" RESOURCE_DISK = "ResourceDisk" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -104,7 +103,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class DiskDeleteOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskDeleteOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the behavior of the managed disk when the VM gets deleted i.e whether the managed disk is deleted or detached. Supported values::code:`
`:code:`
` **Delete** If this value is used, the managed disk is deleted when VM gets deleted.:code:`
`:code:`
` **Detach** @@ -115,7 +114,7 @@ class DiskDeleteOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DELETE = "Delete" DETACH = "Detach" -class DiskDetachOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskDetachOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the detach behavior to be used while detaching a disk or which is already in the process of detachment from the virtual machine. Supported values: **ForceDetach**. :code:`
`:code:`
` detachOption: **ForceDetach** is applicable only for managed data @@ -129,7 +128,7 @@ class DiskDetachOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FORCE_DETACH = "ForceDetach" -class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExecutionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Script execution status. """ @@ -141,41 +140,41 @@ class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TIMED_OUT = "TimedOut" CANCELED = "Canceled" -class ExpandTypesForGetCapacityReservationGroups(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpandTypesForGetCapacityReservationGroups(str, Enum, metaclass=CaseInsensitiveEnumMeta): VIRTUAL_MACHINE_SCALE_SET_VMS_REF = "virtualMachineScaleSetVMs/$ref" VIRTUAL_MACHINES_REF = "virtualMachines/$ref" -class ExpandTypesForGetVMScaleSets(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpandTypesForGetVMScaleSets(str, Enum, metaclass=CaseInsensitiveEnumMeta): USER_DATA = "userData" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class HyperVGenerationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type associated with a resource """ V1 = "V1" V2 = "V2" -class HyperVGenerationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type """ V1 = "V1" V2 = "V2" -class InstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" USER_DATA = "userData" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -184,7 +183,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -193,7 +192,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class IPVersions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -202,7 +201,7 @@ class IPVersions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class LinuxPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinuxPatchAssessmentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` @@ -213,7 +212,7 @@ class LinuxPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class LinuxVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinuxVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's @@ -225,7 +224,7 @@ class LinuxVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -234,14 +233,14 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class NetworkApiVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations """ TWO_THOUSAND_TWENTY11_01 = "2020-11-01" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ @@ -250,34 +249,34 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: Specialized image. Contains already provisioned OS Disk. SPECIALIZED = "Specialized" -class OperatingSystemType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operating system of the osDiskImage. """ WINDOWS = "Windows" LINUX = "Linux" -class OrchestrationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the orchestration mode for the virtual machine scale set. """ UNIFORM = "Uniform" FLEXIBLE = "Flexible" -class OrchestrationServiceNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the service. """ AUTOMATIC_REPAIRS = "AutomaticRepairs" -class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current state of the service. """ @@ -285,21 +284,21 @@ class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enu RUNNING = "Running" SUSPENDED = "Suspended" -class OrchestrationServiceStateAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceStateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The action to be performed. """ RESUME = "Resume" SUSPEND = "Suspend" -class PatchAssessmentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchAssessmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the availability of a given patch. """ UNKNOWN = "Unknown" AVAILABLE = "Available" -class PatchInstallationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchInstallationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the patch after the installation operation completed. """ @@ -310,7 +309,7 @@ class PatchInstallationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) NOT_SELECTED = "NotSelected" PENDING = "Pending" -class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", or "CompletedWithWarnings." @@ -322,7 +321,7 @@ class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -330,7 +329,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -339,28 +338,28 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class PublicIPAddressSkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAddressSkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify public IP sku name """ BASIC = "Basic" STANDARD = "Standard" -class PublicIPAddressSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAddressSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify public IP sku tier """ REGIONAL = "Regional" GLOBAL_ENUM = "Global" -class PublicIPAllocationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify the public IP allocation type """ DYNAMIC = "Dynamic" STATIC = "Static" -class RepairAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RepairAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of repair action (replace, restart, reimage) that will be used for repairing unhealthy virtual machines in the scale set. Default value is replace. """ @@ -369,7 +368,7 @@ class RepairAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESTART = "Restart" REIMAGE = "Reimage" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine. @@ -380,22 +379,22 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RestorePointCollectionExpandOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RestorePointCollectionExpandOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): RESTORE_POINTS = "restorePoints" -class RestorePointExpandOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RestorePointExpandOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -404,7 +403,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SecurityEncryptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SecurityEncryptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the EncryptionType of the managed disk. :code:`
` It is set to DiskWithVMGuestState for encryption of the managed disk along with VMGuestState blob, and VMGuestStateOnly for encryption of just the VMGuestState blob. :code:`
`:code:`
` NOTE: @@ -414,7 +413,7 @@ class SecurityEncryptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) VM_GUEST_STATE_ONLY = "VMGuestStateOnly" DISK_WITH_VM_GUEST_STATE = "DiskWithVMGuestState" -class SecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the SecurityType of the virtual machine. It has to be set to any specified value to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not be enabled unless this property is set. @@ -423,7 +422,7 @@ class SecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TRUSTED_LAUNCH = "TrustedLaunch" CONFIDENTIAL_VM = "ConfidentialVM" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -431,7 +430,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -439,7 +438,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can only be used with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. StandardSSD_LRS uses @@ -457,7 +456,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PREMIUM_ZRS = "Premium_ZRS" STANDARD_SSD_ZRS = "StandardSSD_ZRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -469,7 +468,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -477,7 +476,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -486,14 +485,14 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for the Azure Spot VM/VMSS """ DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for a standalone virtual machine or the virtual machines in the scale set. :code:`
`:code:`
` 'Low' enum will be deprecated in the future, please use 'Spot' as the enum to deploy Azure Spot VM/VMSS. @@ -503,20 +502,20 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E LOW = "Low" SPOT = "Spot" -class VirtualMachineScaleSetScaleInRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "Default" OLDEST_VM = "OldestVM" NEWEST_VM = "NewestVM" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. :code:`
`:code:`
` The enum data type is currently deprecated and will be removed by December 23rd 2023. :code:`
`:code:`
` Recommended way to get the list of available sizes is using these APIs: @@ -698,20 +697,20 @@ class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) STANDARD_NV12 = "Standard_NV12" STANDARD_NV24 = "Standard_NV24" -class VmDiskTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VmDiskTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """VM disk types which are disallowed. """ NONE = "None" UNMANAGED = "Unmanaged" -class VMGuestPatchClassificationLinux(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchClassificationLinux(str, Enum, metaclass=CaseInsensitiveEnumMeta): CRITICAL = "Critical" SECURITY = "Security" OTHER = "Other" -class VMGuestPatchClassificationWindows(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchClassificationWindows(str, Enum, metaclass=CaseInsensitiveEnumMeta): CRITICAL = "Critical" SECURITY = "Security" @@ -722,7 +721,7 @@ class VMGuestPatchClassificationWindows(with_metaclass(CaseInsensitiveEnumMeta, TOOLS = "Tools" UPDATES = "Updates" -class VMGuestPatchRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the reboot requirements of the patch. """ @@ -731,7 +730,7 @@ class VMGuestPatchRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, En ALWAYS_REQUIRES_REBOOT = "AlwaysRequiresReboot" CAN_REQUEST_REBOOT = "CanRequestReboot" -class VMGuestPatchRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines when it is acceptable to reboot a VM during a software update operation. """ @@ -739,7 +738,7 @@ class VMGuestPatchRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enu NEVER = "Never" ALWAYS = "Always" -class VMGuestPatchRebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reboot state of the VM following completion of the operation. """ @@ -750,7 +749,7 @@ class VMGuestPatchRebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" COMPLETED = "Completed" -class WindowsPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WindowsPatchAssessmentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest patch assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` @@ -761,7 +760,7 @@ class WindowsPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, En IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class WindowsVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WindowsVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/_models_py3.py index e3ac5c6ae804..6f23c22ef46c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AdditionalCapabilities(msrest.serialization.Model): @@ -64,7 +66,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2021_11_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -85,7 +87,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -98,7 +100,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2021_11_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -166,8 +168,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -248,7 +250,7 @@ class ApplicationProfile(msrest.serialization.Model): def __init__( self, *, - gallery_applications: Optional[List["VMGalleryApplication"]] = None, + gallery_applications: Optional[List["_models.VMGalleryApplication"]] = None, **kwargs ): """ @@ -351,8 +353,8 @@ class AutomaticRepairsPolicy(msrest.serialization.Model): maximum allowed grace period is 90 minutes (PT90M). :vartype grace_period: str :ivar repair_action: Type of repair action (replace, restart, reimage) that will be used for - repairing unhealthy virtual machines in the scale set. Default value is replace. Possible - values include: "Replace", "Restart", "Reimage". + repairing unhealthy virtual machines in the scale set. Default value is replace. Known values + are: "Replace", "Restart", "Reimage". :vartype repair_action: str or ~azure.mgmt.compute.v2021_11_01.models.RepairAction """ @@ -367,7 +369,7 @@ def __init__( *, enabled: Optional[bool] = None, grace_period: Optional[str] = None, - repair_action: Optional[Union[str, "RepairAction"]] = None, + repair_action: Optional[Union[str, "_models.RepairAction"]] = None, **kwargs ): """ @@ -381,8 +383,8 @@ def __init__( value. The maximum allowed grace period is 90 minutes (PT90M). :paramtype grace_period: str :keyword repair_action: Type of repair action (replace, restart, reimage) that will be used for - repairing unhealthy virtual machines in the scale set. Default value is replace. Possible - values include: "Replace", "Restart", "Reimage". + repairing unhealthy virtual machines in the scale set. Default value is replace. Known values + are: "Replace", "Restart", "Reimage". :paramtype repair_action: str or ~azure.mgmt.compute.v2021_11_01.models.RepairAction """ super(AutomaticRepairsPolicy, self).__init__(**kwargs) @@ -509,11 +511,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -571,7 +573,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -653,11 +655,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -693,8 +695,8 @@ class AvailablePatchSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_11_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -962,7 +964,7 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, **kwargs @@ -1133,7 +1135,7 @@ class CapacityReservationGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["CapacityReservationGroup"], + value: List["_models.CapacityReservationGroup"], next_link: Optional[str] = None, **kwargs ): @@ -1217,8 +1219,8 @@ class CapacityReservationInstanceView(msrest.serialization.Model): def __init__( self, *, - utilization_info: Optional["CapacityReservationUtilization"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + utilization_info: Optional["_models.CapacityReservationUtilization"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1260,8 +1262,8 @@ class CapacityReservationInstanceViewWithName(CapacityReservationInstanceView): def __init__( self, *, - utilization_info: Optional["CapacityReservationUtilization"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + utilization_info: Optional["_models.CapacityReservationUtilization"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1299,7 +1301,7 @@ class CapacityReservationListResult(msrest.serialization.Model): def __init__( self, *, - value: List["CapacityReservation"], + value: List["_models.CapacityReservation"], next_link: Optional[str] = None, **kwargs ): @@ -1332,7 +1334,7 @@ class CapacityReservationProfile(msrest.serialization.Model): def __init__( self, *, - capacity_reservation_group: Optional["SubResource"] = None, + capacity_reservation_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -1401,7 +1403,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -1554,8 +1556,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1566,7 +1567,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1593,14 +1594,14 @@ class DataDisk(msrest.serialization.Model): force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. :code:`
`:code:`
` This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data - disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Possible - values include: "ForceDetach". + disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Known values + are: "ForceDetach". :vartype detach_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskDetachOptionTypes :ivar delete_option: Specifies whether data disk should be deleted or detached upon VM deletion.:code:`
`:code:`
` Possible values: :code:`
`:code:`
` **Delete** If this value is used, the data disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the data disk is retained after VM is deleted.:code:`
`:code:`
` - The default value is set to **detach**. Possible values include: "Delete", "Detach". + The default value is set to **detach**. Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskDeleteOptionTypes """ @@ -1632,17 +1633,17 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, to_be_detached: Optional[bool] = None, - detach_option: Optional[Union[str, "DiskDetachOptionTypes"]] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + detach_option: Optional[Union[str, "_models.DiskDetachOptionTypes"]] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ @@ -1661,8 +1662,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1673,7 +1673,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1692,14 +1692,14 @@ def __init__( force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. :code:`
`:code:`
` This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data - disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Possible - values include: "ForceDetach". + disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Known values + are: "ForceDetach". :paramtype detach_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskDetachOptionTypes :keyword delete_option: Specifies whether data disk should be deleted or detached upon VM deletion.:code:`
`:code:`
` Possible values: :code:`
`:code:`
` **Delete** If this value is used, the data disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the data disk is retained after VM is deleted.:code:`
`:code:`
` - The default value is set to **detach**. Possible values include: "Delete", "Detach". + The default value is set to **detach**. Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskDeleteOptionTypes """ super(DataDisk, self).__init__(**kwargs) @@ -1781,7 +1781,7 @@ class DedicatedHost(Resource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2021_11_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1831,11 +1831,11 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1856,7 +1856,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2021_11_01.models.DedicatedHostLicenseTypes """ @@ -1923,7 +1923,7 @@ class DedicatedHostAvailableCapacity(msrest.serialization.Model): def __init__( self, *, - allocatable_v_ms: Optional[List["DedicatedHostAllocatableVM"]] = None, + allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs ): """ @@ -2045,7 +2045,7 @@ class DedicatedHostGroupInstanceView(msrest.serialization.Model): def __init__( self, *, - hosts: Optional[List["DedicatedHostInstanceViewWithName"]] = None, + hosts: Optional[List["_models.DedicatedHostInstanceViewWithName"]] = None, **kwargs ): """ @@ -2081,7 +2081,7 @@ class DedicatedHostGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHostGroup"], + value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs ): @@ -2199,8 +2199,8 @@ class DedicatedHostInstanceView(msrest.serialization.Model): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2248,8 +2248,8 @@ class DedicatedHostInstanceViewWithName(DedicatedHostInstanceView): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2287,7 +2287,7 @@ class DedicatedHostListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHost"], + value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs ): @@ -2324,7 +2324,7 @@ class DedicatedHostUpdate(UpdateResource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2021_11_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -2366,7 +2366,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -2382,7 +2382,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2021_11_01.models.DedicatedHostLicenseTypes """ @@ -2417,7 +2417,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -2436,8 +2436,8 @@ def __init__( class DiffDiskSettings(msrest.serialization.Model): """Describes the parameters of ephemeral disk settings that can be specified for operating system disk. :code:`
`:code:`
` NOTE: The ephemeral disk settings can only be specified for managed disk. - :ivar option: Specifies the ephemeral disk settings for operating system disk. Possible values - include: "Local". + :ivar option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :vartype option: str or ~azure.mgmt.compute.v2021_11_01.models.DiffDiskOptions :ivar placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -2446,7 +2446,7 @@ class DiffDiskSettings(msrest.serialization.Model): Refer to VM size documentation for Windows VM at https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Possible values include: "CacheDisk", "ResourceDisk". + cache disk. Known values are: "CacheDisk", "ResourceDisk". :vartype placement: str or ~azure.mgmt.compute.v2021_11_01.models.DiffDiskPlacement """ @@ -2458,13 +2458,13 @@ class DiffDiskSettings(msrest.serialization.Model): def __init__( self, *, - option: Optional[Union[str, "DiffDiskOptions"]] = None, - placement: Optional[Union[str, "DiffDiskPlacement"]] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, + placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, **kwargs ): """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. Possible - values include: "Local". + :keyword option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :paramtype option: str or ~azure.mgmt.compute.v2021_11_01.models.DiffDiskOptions :keyword placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -2473,7 +2473,7 @@ def __init__( Refer to VM size documentation for Windows VM at https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Possible values include: "CacheDisk", "ResourceDisk". + cache disk. Known values are: "CacheDisk", "ResourceDisk". :paramtype placement: str or ~azure.mgmt.compute.v2021_11_01.models.DiffDiskPlacement """ super(DiffDiskSettings, self).__init__(**kwargs) @@ -2484,8 +2484,7 @@ def __init__( class DisallowedConfiguration(msrest.serialization.Model): """Specifies the disallowed configuration for a virtual machine image. - :ivar vm_disk_type: VM disk types which are disallowed. Possible values include: "None", - "Unmanaged". + :ivar vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :vartype vm_disk_type: str or ~azure.mgmt.compute.v2021_11_01.models.VmDiskTypes """ @@ -2496,11 +2495,11 @@ class DisallowedConfiguration(msrest.serialization.Model): def __init__( self, *, - vm_disk_type: Optional[Union[str, "VmDiskTypes"]] = None, + vm_disk_type: Optional[Union[str, "_models.VmDiskTypes"]] = None, **kwargs ): """ - :keyword vm_disk_type: VM disk types which are disallowed. Possible values include: "None", + :keyword vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :paramtype vm_disk_type: str or ~azure.mgmt.compute.v2021_11_01.models.VmDiskTypes """ @@ -2578,8 +2577,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -2621,8 +2620,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2703,7 +2702,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.compute.v2021_11_01.models.ExtendedLocationTypes """ @@ -2716,13 +2715,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.compute.v2021_11_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -2744,7 +2743,7 @@ class HardwareProfile(msrest.serialization.Model): `_. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The - available VM sizes depend on region and availability set. Possible values include: "Basic_A0", + available VM sizes depend on region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", @@ -2796,8 +2795,8 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, - vm_size_properties: Optional["VMSizeProperties"] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, + vm_size_properties: Optional["_models.VMSizeProperties"] = None, **kwargs ): """ @@ -2812,7 +2811,7 @@ def __init__( `_. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The - available VM sizes depend on region and availability set. Possible values include: "Basic_A0", + available VM sizes depend on region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", @@ -2888,8 +2887,8 @@ class Image(Resource): :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Possible - values include: "V1", "V2". + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_11_01.models.HyperVGenerationTypes """ @@ -2920,10 +2919,10 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -2941,7 +2940,7 @@ def __init__( from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the user to specify the property if we cannot deduce it from the source managed - resource. Possible values include: "V1", "V2". + resource. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_11_01.models.HyperVGenerationTypes """ @@ -2965,16 +2964,15 @@ class ImageDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_11_01.models.StorageAccountTypes @@ -2997,13 +2995,13 @@ class ImageDisk(msrest.serialization.Model): def __init__( self, *, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3016,16 +3014,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_11_01.models.StorageAccountTypes @@ -3058,16 +3055,15 @@ class ImageDataDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_11_01.models.StorageAccountTypes @@ -3100,13 +3096,13 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3119,16 +3115,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_11_01.models.StorageAccountTypes @@ -3169,7 +3164,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -3199,16 +3194,15 @@ class ImageOSDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_11_01.models.StorageAccountTypes @@ -3218,10 +3212,10 @@ class ImageOSDisk(ImageDisk): ~azure.mgmt.compute.v2021_11_01.models.DiskEncryptionSetParameters :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemStateTypes """ @@ -3245,15 +3239,15 @@ class ImageOSDisk(ImageDisk): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3266,16 +3260,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_11_01.models.StorageAccountTypes @@ -3285,11 +3278,10 @@ def __init__( ~azure.mgmt.compute.v2021_11_01.models.DiskEncryptionSetParameters :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemStateTypes """ super(ImageOSDisk, self).__init__(snapshot=snapshot, managed_disk=managed_disk, blob_uri=blob_uri, caching=caching, disk_size_gb=disk_size_gb, storage_account_type=storage_account_type, disk_encryption_set=disk_encryption_set, **kwargs) @@ -3424,8 +3416,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -3466,8 +3458,8 @@ class ImageUpdate(UpdateResource): :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Possible - values include: "V1", "V2". + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_11_01.models.HyperVGenerationTypes """ @@ -3488,9 +3480,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -3504,7 +3496,7 @@ def __init__( from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the user to specify the property if we cannot deduce it from the source managed - resource. Possible values include: "V1", "V2". + resource. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_11_01.models.HyperVGenerationTypes """ @@ -3552,7 +3544,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2021_11_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -3574,7 +3566,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -3583,7 +3575,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2021_11_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -3625,7 +3617,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -3664,7 +3656,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -3685,8 +3677,8 @@ class LastPatchInstallationSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_11_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -3793,9 +3785,9 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, provision_vm_agent: Optional[bool] = None, - patch_settings: Optional["LinuxPatchSettings"] = None, + patch_settings: Optional["_models.LinuxPatchSettings"] = None, **kwargs ): """ @@ -3848,7 +3840,7 @@ class LinuxParameters(msrest.serialization.Model): def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "VMGuestPatchClassificationLinux"]]] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationLinux"]]] = None, package_name_masks_to_include: Optional[List[str]] = None, package_name_masks_to_exclude: Optional[List[str]] = None, maintenance_run_id: Optional[str] = None, @@ -3884,15 +3876,15 @@ class LinuxPatchSettings(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. Possible values include: "ImageDefault", + The property provisionVMAgent must be true. Known values are: "ImageDefault", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2021_11_01.models.LinuxVMGuestPatchMode :ivar assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :vartype assessment_mode: str or ~azure.mgmt.compute.v2021_11_01.models.LinuxPatchAssessmentMode """ @@ -3905,8 +3897,8 @@ class LinuxPatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "LinuxVMGuestPatchMode"]] = None, - assessment_mode: Optional[Union[str, "LinuxPatchAssessmentMode"]] = None, + patch_mode: Optional[Union[str, "_models.LinuxVMGuestPatchMode"]] = None, + assessment_mode: Optional[Union[str, "_models.LinuxPatchAssessmentMode"]] = None, **kwargs ): """ @@ -3915,15 +3907,15 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. Possible values include: "ImageDefault", + The property provisionVMAgent must be true. Known values are: "ImageDefault", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2021_11_01.models.LinuxVMGuestPatchMode :keyword assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :paramtype assessment_mode: str or ~azure.mgmt.compute.v2021_11_01.models.LinuxPatchAssessmentMode """ @@ -3956,7 +3948,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -4124,8 +4116,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2021_11_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -4150,7 +4142,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -4166,8 +4158,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2021_11_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -4189,8 +4181,8 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_11_01.models.StorageAccountTypes @@ -4213,17 +4205,17 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, - security_profile: Optional["VMDiskSecurityProfile"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, + security_profile: Optional["_models.VMDiskSecurityProfile"] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_11_01.models.StorageAccountTypes @@ -4249,7 +4241,7 @@ class NetworkInterfaceReference(SubResource): than 1 network interface. :vartype primary: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions """ @@ -4264,7 +4256,7 @@ def __init__( *, id: Optional[str] = None, primary: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -4274,7 +4266,7 @@ def __init__( than 1 network interface. :paramtype primary: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions """ super(NetworkInterfaceReference, self).__init__(id=id, **kwargs) @@ -4290,8 +4282,7 @@ class NetworkProfile(msrest.serialization.Model): :vartype network_interfaces: list[~azure.mgmt.compute.v2021_11_01.models.NetworkInterfaceReference] :ivar network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. Possible values include: - "2020-11-01". + networking resources in the Network Interface Configurations. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2021_11_01.models.NetworkApiVersion :ivar network_interface_configurations: Specifies the networking configurations that will be used to create the virtual machine networking resources. @@ -4308,9 +4299,9 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, - network_interface_configurations: Optional[List["VirtualMachineNetworkInterfaceConfiguration"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceConfiguration"]] = None, **kwargs ): """ @@ -4319,8 +4310,7 @@ def __init__( :paramtype network_interfaces: list[~azure.mgmt.compute.v2021_11_01.models.NetworkInterfaceReference] :keyword network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. Possible values include: - "2020-11-01". + networking resources in the Network Interface Configurations. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_11_01.models.NetworkApiVersion :keyword network_interface_configurations: Specifies the networking configurations that will be used to create the virtual machine networking resources. @@ -4338,11 +4328,9 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :ivar service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2021_11_01.models.OrchestrationServiceNames - :ivar action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :ivar action: Required. The action to be performed. Known values are: "Resume", "Suspend". :vartype action: str or ~azure.mgmt.compute.v2021_11_01.models.OrchestrationServiceStateAction """ @@ -4359,17 +4347,15 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): def __init__( self, *, - service_name: Union[str, "OrchestrationServiceNames"], - action: Union[str, "OrchestrationServiceStateAction"], + service_name: Union[str, "_models.OrchestrationServiceNames"], + action: Union[str, "_models.OrchestrationServiceStateAction"], **kwargs ): """ - :keyword service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs". + :keyword service_name: Required. The name of the service. Known values are: "AutomaticRepairs". :paramtype service_name: str or ~azure.mgmt.compute.v2021_11_01.models.OrchestrationServiceNames - :keyword action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :keyword action: Required. The action to be performed. Known values are: "Resume", "Suspend". :paramtype action: str or ~azure.mgmt.compute.v2021_11_01.models.OrchestrationServiceStateAction """ @@ -4383,9 +4369,9 @@ class OrchestrationServiceSummary(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar service_name: The name of the service. Possible values include: "AutomaticRepairs". + :ivar service_name: The name of the service. Known values are: "AutomaticRepairs". :vartype service_name: str or ~azure.mgmt.compute.v2021_11_01.models.OrchestrationServiceNames - :ivar service_state: The current state of the service. Possible values include: "NotRunning", + :ivar service_state: The current state of the service. Known values are: "NotRunning", "Running", "Suspended". :vartype service_state: str or ~azure.mgmt.compute.v2021_11_01.models.OrchestrationServiceState """ @@ -4418,8 +4404,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -4435,8 +4421,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -4450,7 +4435,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -4463,8 +4448,8 @@ class OSDisk(msrest.serialization.Model): used, the OS disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the os disk is retained after VM is deleted. :code:`
`:code:`
` The default value is set to **detach**. For an ephemeral OS Disk, the default value is set to - **Delete**. User cannot change the delete option for ephemeral OS Disk. Possible values - include: "Delete", "Detach". + **Delete**. User cannot change the delete option for ephemeral OS Disk. Known values are: + "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskDeleteOptionTypes """ @@ -4490,25 +4475,25 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -4524,8 +4509,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -4539,7 +4523,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -4552,8 +4536,8 @@ def __init__( value is used, the OS disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the os disk is retained after VM is deleted. :code:`
`:code:`
` The default value is set to **detach**. For an ephemeral OS Disk, the default value is set to - **Delete**. User cannot change the delete option for ephemeral OS Disk. Possible values - include: "Delete", "Detach". + **Delete**. User cannot change the delete option for ephemeral OS Disk. Known values are: + "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskDeleteOptionTypes """ super(OSDisk, self).__init__(**kwargs) @@ -4576,8 +4560,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemTypes """ @@ -4592,12 +4576,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -4693,9 +4677,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, require_guest_provision_signal: Optional[bool] = None, **kwargs @@ -4797,8 +4781,7 @@ class PatchInstallationDetail(msrest.serialization.Model): :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] :ivar installation_state: The state of the patch after the installation operation completed. - Possible values include: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", - "Pending". + Known values are: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", "Pending". :vartype installation_state: str or ~azure.mgmt.compute.v2021_11_01.models.PatchInstallationState """ @@ -4848,8 +4831,8 @@ class PatchSettings(msrest.serialization.Model): **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2021_11_01.models.WindowsVMGuestPatchMode :ivar enable_hotpatching: Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must @@ -4859,8 +4842,8 @@ class PatchSettings(msrest.serialization.Model): machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :vartype assessment_mode: str or ~azure.mgmt.compute.v2021_11_01.models.WindowsPatchAssessmentMode """ @@ -4874,9 +4857,9 @@ class PatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "WindowsVMGuestPatchMode"]] = None, + patch_mode: Optional[Union[str, "_models.WindowsVMGuestPatchMode"]] = None, enable_hotpatching: Optional[bool] = None, - assessment_mode: Optional[Union[str, "WindowsPatchAssessmentMode"]] = None, + assessment_mode: Optional[Union[str, "_models.WindowsPatchAssessmentMode"]] = None, **kwargs ): """ @@ -4889,8 +4872,8 @@ def __init__( **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2021_11_01.models.WindowsVMGuestPatchMode :keyword enable_hotpatching: Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must @@ -4900,8 +4883,8 @@ def __init__( machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :paramtype assessment_mode: str or ~azure.mgmt.compute.v2021_11_01.models.WindowsPatchAssessmentMode """ @@ -4979,7 +4962,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2021_11_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -5026,8 +5009,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -5038,7 +5021,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2021_11_01.models.ProximityPlacementGroupType :keyword colocation_status: Describes colocation status of the Proximity Placement Group. @@ -5075,7 +5058,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -5154,9 +5137,9 @@ def __init__( class PublicIPAddressSku(msrest.serialization.Model): """Describes the public IP Sku. It can only be set with OrchestrationMode as Flexible. - :ivar name: Specify public IP sku name. Possible values include: "Basic", "Standard". + :ivar name: Specify public IP sku name. Known values are: "Basic", "Standard". :vartype name: str or ~azure.mgmt.compute.v2021_11_01.models.PublicIPAddressSkuName - :ivar tier: Specify public IP sku tier. Possible values include: "Regional", "Global". + :ivar tier: Specify public IP sku tier. Known values are: "Regional", "Global". :vartype tier: str or ~azure.mgmt.compute.v2021_11_01.models.PublicIPAddressSkuTier """ @@ -5168,14 +5151,14 @@ class PublicIPAddressSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "PublicIPAddressSkuName"]] = None, - tier: Optional[Union[str, "PublicIPAddressSkuTier"]] = None, + name: Optional[Union[str, "_models.PublicIPAddressSkuName"]] = None, + tier: Optional[Union[str, "_models.PublicIPAddressSkuTier"]] = None, **kwargs ): """ - :keyword name: Specify public IP sku name. Possible values include: "Basic", "Standard". + :keyword name: Specify public IP sku name. Known values are: "Basic", "Standard". :paramtype name: str or ~azure.mgmt.compute.v2021_11_01.models.PublicIPAddressSkuName - :keyword tier: Specify public IP sku tier. Possible values include: "Regional", "Global". + :keyword tier: Specify public IP sku tier. Known values are: "Regional", "Global". :paramtype tier: str or ~azure.mgmt.compute.v2021_11_01.models.PublicIPAddressSkuTier """ super(PublicIPAddressSku, self).__init__(**kwargs) @@ -5288,7 +5271,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_user_agent: Group query result by User Agent. :vartype group_by_user_agent: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2021_11_01.models.IntervalInMins """ @@ -5317,7 +5300,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -5344,7 +5327,7 @@ def __init__( :keyword group_by_user_agent: Group query result by User Agent. :paramtype group_by_user_agent: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2021_11_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, group_by_client_application_id=group_by_client_application_id, group_by_user_agent=group_by_user_agent, **kwargs) @@ -5371,7 +5354,7 @@ class RestorePoint(ProxyResource): :ivar provisioning_state: Gets the provisioning state of the restore point. :vartype provisioning_state: str :ivar consistency_mode: Gets the consistency mode for the restore point. Please refer to - https://aka.ms/RestorePoints for more details. Possible values include: "CrashConsistent", + https://aka.ms/RestorePoints for more details. Known values are: "CrashConsistent", "FileSystemConsistent", "ApplicationConsistent". :vartype consistency_mode: str or ~azure.mgmt.compute.v2021_11_01.models.ConsistencyModeTypes :ivar time_created: Gets the creation time of the restore point. @@ -5409,9 +5392,9 @@ class RestorePoint(ProxyResource): def __init__( self, *, - exclude_disks: Optional[List["ApiEntityReference"]] = None, + exclude_disks: Optional[List["_models.ApiEntityReference"]] = None, time_created: Optional[datetime.datetime] = None, - source_restore_point: Optional["ApiEntityReference"] = None, + source_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs ): """ @@ -5490,7 +5473,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source: Optional["RestorePointCollectionSourceProperties"] = None, + source: Optional["_models.RestorePointCollectionSourceProperties"] = None, **kwargs ): """ @@ -5528,7 +5511,7 @@ class RestorePointCollectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RestorePointCollection"]] = None, + value: Optional[List["_models.RestorePointCollection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -5616,7 +5599,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["RestorePointCollectionSourceProperties"] = None, + source: Optional["_models.RestorePointCollectionSourceProperties"] = None, **kwargs ): """ @@ -5652,8 +5635,8 @@ class RestorePointInstanceView(msrest.serialization.Model): def __init__( self, *, - disk_restore_points: Optional[List["DiskRestorePointInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + disk_restore_points: Optional[List["_models.DiskRestorePointInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -5704,13 +5687,13 @@ class RestorePointSourceMetadata(msrest.serialization.Model): def __init__( self, *, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["RestorePointSourceVMStorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.RestorePointSourceVMStorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, license_type: Optional[str] = None, vm_id: Optional[str] = None, - security_profile: Optional["SecurityProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, location: Optional[str] = None, **kwargs ): @@ -5751,7 +5734,7 @@ class RestorePointSourceVMDataDisk(msrest.serialization.Model): :vartype lun: int :ivar name: Gets the disk name. :vartype name: str - :ivar caching: Gets the caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :ivar disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired size for existing OS and Data disks. @@ -5776,10 +5759,10 @@ def __init__( *, lun: Optional[int] = None, name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - disk_restore_point: Optional["ApiEntityReference"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + disk_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs ): """ @@ -5787,8 +5770,7 @@ def __init__( :paramtype lun: int :keyword name: Gets the disk name. :paramtype name: str - :keyword caching: Gets the caching type. Possible values include: "None", "ReadOnly", - "ReadWrite". + :keyword caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :keyword disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired size for existing OS and Data disks. @@ -5810,13 +5792,13 @@ def __init__( class RestorePointSourceVMOSDisk(msrest.serialization.Model): """Describes an Operating System disk. - :ivar os_type: Gets the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: Gets the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemType :ivar encryption_settings: Gets the disk encryption settings. :vartype encryption_settings: ~azure.mgmt.compute.v2021_11_01.models.DiskEncryptionSettings :ivar name: Gets the disk name. :vartype name: str - :ivar caching: Gets the caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :ivar disk_size_gb: Gets the disk size in GB. :vartype disk_size_gb: int @@ -5839,24 +5821,23 @@ class RestorePointSourceVMOSDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Optional[Union[str, "OperatingSystemType"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemType"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - disk_restore_point: Optional["ApiEntityReference"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + disk_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs ): """ - :keyword os_type: Gets the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: Gets the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemType :keyword encryption_settings: Gets the disk encryption settings. :paramtype encryption_settings: ~azure.mgmt.compute.v2021_11_01.models.DiskEncryptionSettings :keyword name: Gets the disk name. :paramtype name: str - :keyword caching: Gets the caching type. Possible values include: "None", "ReadOnly", - "ReadWrite". + :keyword caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :keyword disk_size_gb: Gets the disk size in GB. :paramtype disk_size_gb: int @@ -5893,8 +5874,8 @@ class RestorePointSourceVMStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["RestorePointSourceVMOSDisk"] = None, - data_disks: Optional[List["RestorePointSourceVMDataDisk"]] = None, + os_disk: Optional["_models.RestorePointSourceVMOSDisk"] = None, + data_disks: Optional[List["_models.RestorePointSourceVMDataDisk"]] = None, **kwargs ): """ @@ -6125,13 +6106,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2021_11_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2021_11_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -6244,8 +6225,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -6274,7 +6254,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -6284,8 +6264,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -6309,8 +6288,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -6346,11 +6324,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -6358,8 +6336,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -6405,7 +6382,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -6486,7 +6463,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -6569,7 +6546,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -6613,7 +6590,7 @@ class ScaleInPolicy(msrest.serialization.Model): def __init__( self, *, - rules: Optional[List[Union[str, "VirtualMachineScaleSetScaleInRules"]]] = None, + rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, force_deletion: Optional[bool] = None, **kwargs ): @@ -6660,7 +6637,7 @@ class ScheduledEventsProfile(msrest.serialization.Model): def __init__( self, *, - terminate_notification_profile: Optional["TerminateNotificationProfile"] = None, + terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs ): """ @@ -6687,8 +6664,7 @@ class SecurityProfile(msrest.serialization.Model): :vartype encryption_at_host: bool :ivar security_type: Specifies the SecurityType of the virtual machine. It has to be set to any specified value to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not - be enabled unless this property is set. Possible values include: "TrustedLaunch", - "ConfidentialVM". + be enabled unless this property is set. Known values are: "TrustedLaunch", "ConfidentialVM". :vartype security_type: str or ~azure.mgmt.compute.v2021_11_01.models.SecurityTypes """ @@ -6701,9 +6677,9 @@ class SecurityProfile(msrest.serialization.Model): def __init__( self, *, - uefi_settings: Optional["UefiSettings"] = None, + uefi_settings: Optional["_models.UefiSettings"] = None, encryption_at_host: Optional[bool] = None, - security_type: Optional[Union[str, "SecurityTypes"]] = None, + security_type: Optional[Union[str, "_models.SecurityTypes"]] = None, **kwargs ): """ @@ -6718,7 +6694,7 @@ def __init__( :paramtype encryption_at_host: bool :keyword security_type: Specifies the SecurityType of the virtual machine. It has to be set to any specified value to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will - not be enabled unless this property is set. Possible values include: "TrustedLaunch", + not be enabled unless this property is set. Known values are: "TrustedLaunch", "ConfidentialVM". :paramtype security_type: str or ~azure.mgmt.compute.v2021_11_01.models.SecurityTypes """ @@ -6822,7 +6798,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -7017,7 +6993,7 @@ class SshPublicKeysGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["SshPublicKeyResource"], + value: List["_models.SshPublicKeyResource"], next_link: Optional[str] = None, **kwargs ): @@ -7099,9 +7075,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -7173,7 +7149,7 @@ def __init__( self, *, id: Optional[str] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -7386,7 +7362,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2021_11_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2021_11_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2021_11_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -7433,7 +7409,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2021_11_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -7473,8 +7449,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2021_11_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -7494,9 +7470,9 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["AutomaticOSUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, + automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, **kwargs ): """ @@ -7504,8 +7480,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2021_11_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -7559,7 +7535,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -7721,8 +7697,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -7839,14 +7815,13 @@ class VirtualMachine(Resource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_11_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -7965,32 +7940,32 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, platform_fault_domain: Optional[int] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, - capacity_reservation: Optional["CapacityReservationProfile"] = None, - application_profile: Optional["ApplicationProfile"] = None, + capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, + application_profile: Optional["_models.ApplicationProfile"] = None, **kwargs ): """ @@ -8056,15 +8031,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_11_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -8172,8 +8146,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -8198,8 +8172,8 @@ class VirtualMachineAssessPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_11_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -8455,7 +8429,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, suppress_failures: Optional[bool] = None, protected_settings_from_key_vault: Optional[Any] = None, **kwargs @@ -8535,7 +8509,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -8672,8 +8646,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -8710,7 +8684,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -8871,8 +8845,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2021_11_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -8896,15 +8870,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2021_11_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -8958,7 +8932,7 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, **kwargs ): """ @@ -9009,8 +8983,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2021_11_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: "V1", - "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_11_01.models.HyperVGenerationTypes :ivar disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -9018,7 +8991,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :vartype disallowed: ~azure.mgmt.compute.v2021_11_01.models.DisallowedConfiguration :ivar features: :vartype features: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageFeature] - :ivar architecture: Specifies the Architecture Type. Possible values include: "x64", "Arm64". + :ivar architecture: Specifies the Architecture Type. Known values are: "x64", "Arm64". :vartype architecture: str or ~azure.mgmt.compute.v2021_11_01.models.ArchitectureTypes """ @@ -9050,15 +9023,15 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, - disallowed: Optional["DisallowedConfiguration"] = None, - features: Optional[List["VirtualMachineImageFeature"]] = None, - architecture: Optional[Union[str, "ArchitectureTypes"]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, + automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, + disallowed: Optional["_models.DisallowedConfiguration"] = None, + features: Optional[List["_models.VirtualMachineImageFeature"]] = None, + architecture: Optional[Union[str, "_models.ArchitectureTypes"]] = None, **kwargs ): """ @@ -9085,8 +9058,7 @@ def __init__( image. :paramtype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2021_11_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: - "V1", "V2". + :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_11_01.models.HyperVGenerationTypes :keyword disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -9094,8 +9066,7 @@ def __init__( :paramtype disallowed: ~azure.mgmt.compute.v2021_11_01.models.DisallowedConfiguration :keyword features: :paramtype features: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageFeature] - :keyword architecture: Specifies the Architecture Type. Possible values include: "x64", - "Arm64". + :keyword architecture: Specifies the Architecture Type. Known values are: "x64", "Arm64". :paramtype architecture: str or ~azure.mgmt.compute.v2021_11_01.models.ArchitectureTypes """ super(VirtualMachineImage, self).__init__(id=id, name=name, location=location, tags=tags, extended_location=extended_location, **kwargs) @@ -9150,7 +9121,7 @@ class VirtualMachineInstallPatchesParameters(msrest.serialization.Model): must be an ISO 8601-compliant duration string such as PT4H (4 hours). :vartype maximum_duration: str :ivar reboot_setting: Required. Defines when it is acceptable to reboot a VM during a software - update operation. Possible values include: "IfRequired", "Never", "Always". + update operation. Known values are: "IfRequired", "Never", "Always". :vartype reboot_setting: str or ~azure.mgmt.compute.v2021_11_01.models.VMGuestPatchRebootSetting :ivar windows_parameters: Input for InstallPatches on a Windows VM, as directly received by the @@ -9175,10 +9146,10 @@ class VirtualMachineInstallPatchesParameters(msrest.serialization.Model): def __init__( self, *, - reboot_setting: Union[str, "VMGuestPatchRebootSetting"], + reboot_setting: Union[str, "_models.VMGuestPatchRebootSetting"], maximum_duration: Optional[str] = None, - windows_parameters: Optional["WindowsParameters"] = None, - linux_parameters: Optional["LinuxParameters"] = None, + windows_parameters: Optional["_models.WindowsParameters"] = None, + linux_parameters: Optional["_models.LinuxParameters"] = None, **kwargs ): """ @@ -9186,7 +9157,7 @@ def __init__( must be an ISO 8601-compliant duration string such as PT4H (4 hours). :paramtype maximum_duration: str :keyword reboot_setting: Required. Defines when it is acceptable to reboot a VM during a - software update operation. Possible values include: "IfRequired", "Never", "Always". + software update operation. Known values are: "IfRequired", "Never", "Always". :paramtype reboot_setting: str or ~azure.mgmt.compute.v2021_11_01.models.VMGuestPatchRebootSetting :keyword windows_parameters: Input for InstallPatches on a Windows VM, as directly received by @@ -9210,14 +9181,14 @@ class VirtualMachineInstallPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Failed", "Succeeded", "Unknown" or - "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2021_11_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. :vartype installation_activity_id: str - :ivar reboot_status: The reboot state of the VM following completion of the operation. Possible - values include: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". + :ivar reboot_status: The reboot state of the VM following completion of the operation. Known + values are: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". :vartype reboot_status: str or ~azure.mgmt.compute.v2021_11_01.models.VMGuestPatchRebootStatus :ivar maintenance_window_exceeded: Whether the operation ran out of time before it completed all its intended actions. @@ -9312,8 +9283,8 @@ class VirtualMachineInstanceView(msrest.serialization.Model): :vartype os_name: str :ivar os_version: The version of Operating System running on the virtual machine. :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_11_01.models.HyperVGenerationType :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. :vartype rdp_thumb_print: str @@ -9377,15 +9348,15 @@ def __init__( computer_name: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationType"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, - patch_status: Optional["VirtualMachinePatchStatus"] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, + patch_status: Optional["_models.VirtualMachinePatchStatus"] = None, **kwargs ): """ @@ -9400,7 +9371,7 @@ def __init__( :keyword os_version: The version of Operating System running on the virtual machine. :paramtype os_version: str :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_11_01.models.HyperVGenerationType :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. @@ -9500,7 +9471,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -9527,7 +9498,7 @@ class VirtualMachineNetworkInterfaceConfiguration(msrest.serialization.Model): than 1 network interface. :vartype primary: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated networking-enabled. @@ -9570,14 +9541,14 @@ def __init__( *, name: str, primary: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, enable_ip_forwarding: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineNetworkInterfaceDnsSettingsConfiguration"] = None, - ip_configurations: Optional[List["VirtualMachineNetworkInterfaceIPConfiguration"]] = None, - dscp_configuration: Optional["SubResource"] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineNetworkInterfaceDnsSettingsConfiguration"] = None, + ip_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceIPConfiguration"]] = None, + dscp_configuration: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -9587,7 +9558,7 @@ def __init__( than 1 network interface. :paramtype primary: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated networking-enabled. @@ -9662,7 +9633,7 @@ class VirtualMachineNetworkInterfaceIPConfiguration(msrest.serialization.Model): ~azure.mgmt.compute.v2021_11_01.models.VirtualMachinePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_11_01.models.IPVersions :ivar application_security_groups: Specifies an array of references to application security group. @@ -9700,13 +9671,13 @@ def __init__( self, *, name: str, - subnet: Optional["SubResource"] = None, + subnet: Optional["_models.SubResource"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachinePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersions"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachinePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersions"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -9722,7 +9693,7 @@ def __init__( ~azure.mgmt.compute.v2021_11_01.models.VirtualMachinePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_11_01.models.IPVersions :keyword application_security_groups: Specifies an array of references to application security group. @@ -9782,8 +9753,8 @@ class VirtualMachinePatchStatus(msrest.serialization.Model): def __init__( self, *, - available_patch_summary: Optional["AvailablePatchSummary"] = None, - last_patch_installation_summary: Optional["LastPatchInstallationSummary"] = None, + available_patch_summary: Optional["_models.AvailablePatchSummary"] = None, + last_patch_installation_summary: Optional["_models.LastPatchInstallationSummary"] = None, **kwargs ): """ @@ -9814,7 +9785,7 @@ class VirtualMachinePublicIPAddressConfiguration(msrest.serialization.Model): :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. :vartype idle_timeout_in_minutes: int :ivar delete_option: Specify what happens to the public IP address when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions :ivar dns_settings: The dns settings to be applied on the publicIP addresses . :vartype dns_settings: @@ -9825,10 +9796,10 @@ class VirtualMachinePublicIPAddressConfiguration(msrest.serialization.Model): :vartype public_ip_prefix: ~azure.mgmt.compute.v2021_11_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2021_11_01.models.IPVersions - :ivar public_ip_allocation_method: Specify the public IP allocation type. Possible values - include: "Dynamic", "Static". + :ivar public_ip_allocation_method: Specify the public IP allocation type. Known values are: + "Dynamic", "Static". :vartype public_ip_allocation_method: str or ~azure.mgmt.compute.v2021_11_01.models.PublicIPAllocationMethod """ @@ -9853,14 +9824,14 @@ def __init__( self, *, name: str, - sku: Optional["PublicIPAddressSku"] = None, + sku: Optional["_models.PublicIPAddressSku"] = None, idle_timeout_in_minutes: Optional[int] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, - dns_settings: Optional["VirtualMachinePublicIPAddressDnsSettingsConfiguration"] = None, - ip_tags: Optional[List["VirtualMachineIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersions"]] = None, - public_ip_allocation_method: Optional[Union[str, "PublicIPAllocationMethod"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachinePublicIPAddressDnsSettingsConfiguration"] = None, + ip_tags: Optional[List["_models.VirtualMachineIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersions"]] = None, + public_ip_allocation_method: Optional[Union[str, "_models.PublicIPAllocationMethod"]] = None, **kwargs ): """ @@ -9872,7 +9843,7 @@ def __init__( :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. :paramtype idle_timeout_in_minutes: int :keyword delete_option: Specify what happens to the public IP address when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions :keyword dns_settings: The dns settings to be applied on the publicIP addresses . :paramtype dns_settings: @@ -9883,10 +9854,10 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2021_11_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2021_11_01.models.IPVersions - :keyword public_ip_allocation_method: Specify the public IP allocation type. Possible values - include: "Dynamic", "Static". + :keyword public_ip_allocation_method: Specify the public IP allocation type. Known values are: + "Dynamic", "Static". :paramtype public_ip_allocation_method: str or ~azure.mgmt.compute.v2021_11_01.models.PublicIPAllocationMethod """ @@ -10044,9 +10015,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -10101,7 +10072,7 @@ def __init__( class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): """The instance view of a virtual machine run command. - :ivar execution_state: Script execution status. Possible values include: "Unknown", "Pending", + :ivar execution_state: Script execution status. Known values are: "Unknown", "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :vartype execution_state: str or ~azure.mgmt.compute.v2021_11_01.models.ExecutionState :ivar execution_message: Communicate script configuration errors or execution messages. @@ -10134,19 +10105,19 @@ class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): def __init__( self, *, - execution_state: Optional[Union[str, "ExecutionState"]] = None, + execution_state: Optional[Union[str, "_models.ExecutionState"]] = None, execution_message: Optional[str] = None, exit_code: Optional[int] = None, output: Optional[str] = None, error: Optional[str] = None, start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ - :keyword execution_state: Script execution status. Possible values include: "Unknown", - "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". + :keyword execution_state: Script execution status. Known values are: "Unknown", "Pending", + "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :paramtype execution_state: str or ~azure.mgmt.compute.v2021_11_01.models.ExecutionState :keyword execution_message: Communicate script configuration errors or execution messages. :paramtype execution_message: str @@ -10236,7 +10207,7 @@ class VirtualMachineRunCommandsListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineRunCommand"], + value: List["_models.VirtualMachineRunCommand"], next_link: Optional[str] = None, **kwargs ): @@ -10312,9 +10283,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -10441,7 +10412,7 @@ class VirtualMachineScaleSet(Resource): Virtual Machine Scale Set. :vartype scale_in_policy: ~azure.mgmt.compute.v2021_11_01.models.ScaleInPolicy :ivar orchestration_mode: Specifies the orchestration mode for the virtual machine scale set. - Possible values include: "Uniform", "Flexible". + Known values are: "Uniform", "Flexible". :vartype orchestration_mode: str or ~azure.mgmt.compute.v2021_11_01.models.OrchestrationMode :ivar spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale set. @@ -10496,25 +10467,25 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - orchestration_mode: Optional[Union[str, "OrchestrationMode"]] = None, - spot_restore_policy: Optional["SpotRestorePolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + orchestration_mode: Optional[Union[str, "_models.OrchestrationMode"]] = None, + spot_restore_policy: Optional["_models.SpotRestorePolicy"] = None, **kwargs ): """ @@ -10580,7 +10551,7 @@ def __init__( the Virtual Machine Scale Set. :paramtype scale_in_policy: ~azure.mgmt.compute.v2021_11_01.models.ScaleInPolicy :keyword orchestration_mode: Specifies the orchestration mode for the virtual machine scale - set. Possible values include: "Uniform", "Flexible". + set. Known values are: "Uniform", "Flexible". :paramtype orchestration_mode: str or ~azure.mgmt.compute.v2021_11_01.models.OrchestrationMode :keyword spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale set. @@ -10625,14 +10596,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -10672,12 +10642,12 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, **kwargs @@ -10692,14 +10662,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -10894,7 +10863,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -10931,7 +10900,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, extensions_time_budget: Optional[str] = None, **kwargs ): @@ -11105,7 +11074,7 @@ class VirtualMachineScaleSetHardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size_properties: Optional["VMSizeProperties"] = None, + vm_size_properties: Optional["_models.VMSizeProperties"] = None, **kwargs ): """ @@ -11132,7 +11101,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2021_11_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine @@ -11157,15 +11126,15 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2021_11_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual @@ -11248,7 +11217,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -11309,7 +11278,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_11_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -11353,14 +11322,14 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -11378,7 +11347,7 @@ def __init__( ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_11_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -11470,7 +11439,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -11511,7 +11480,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -11551,7 +11520,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -11591,7 +11560,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -11611,8 +11580,8 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): """Describes the parameters of a ScaleSet managed disk. :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2021_11_01.models.StorageAccountTypes @@ -11633,15 +11602,15 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, - security_profile: Optional["VMDiskSecurityProfile"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, + security_profile: Optional["_models.VMDiskSecurityProfile"] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2021_11_01.models.StorageAccountTypes @@ -11686,7 +11655,7 @@ class VirtualMachineScaleSetNetworkConfiguration(SubResource): :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions """ @@ -11715,11 +11684,11 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -11746,7 +11715,7 @@ def __init__( :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions """ super(VirtualMachineScaleSetNetworkConfiguration, self).__init__(id=id, **kwargs) @@ -11798,7 +11767,7 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetNetworkConfiguration] :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2021_11_01.models.NetworkApiVersion """ @@ -11811,9 +11780,9 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, **kwargs ): """ @@ -11826,7 +11795,7 @@ def __init__( list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetNetworkConfiguration] :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_11_01.models.NetworkApiVersion """ super(VirtualMachineScaleSetNetworkProfile, self).__init__(**kwargs) @@ -11845,8 +11814,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -11855,8 +11823,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -11867,8 +11835,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2021_11_01.models.VirtualHardDisk @@ -11900,16 +11868,16 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ @@ -11918,8 +11886,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -11928,8 +11895,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2021_11_01.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -11941,7 +11908,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_11_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2021_11_01.models.VirtualHardDisk @@ -12040,9 +12007,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, **kwargs ): @@ -12132,10 +12099,10 @@ class VirtualMachineScaleSetPublicIPAddressConfiguration(msrest.serialization.Mo :vartype public_ip_prefix: ~azure.mgmt.compute.v2021_11_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2021_11_01.models.IPVersion - :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values + are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions """ @@ -12158,13 +12125,13 @@ def __init__( self, *, name: str, - sku: Optional["PublicIPAddressSku"] = None, + sku: Optional["_models.PublicIPAddressSku"] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -12184,10 +12151,10 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2021_11_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2021_11_01.models.IPVersion - :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known + values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions """ super(VirtualMachineScaleSetPublicIPAddressConfiguration, self).__init__(**kwargs) @@ -12347,8 +12314,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -12410,9 +12376,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -12503,18 +12469,18 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - proximity_placement_group: Optional["SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -12592,7 +12558,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2021_11_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -12626,14 +12592,14 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -12651,7 +12617,7 @@ def __init__( ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2021_11_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -12705,7 +12671,7 @@ class VirtualMachineScaleSetUpdateNetworkConfiguration(SubResource): :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions """ @@ -12730,11 +12696,11 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -12760,7 +12726,7 @@ def __init__( :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions """ super(VirtualMachineScaleSetUpdateNetworkConfiguration, self).__init__(id=id, **kwargs) @@ -12787,7 +12753,7 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2021_11_01.models.NetworkApiVersion """ @@ -12800,9 +12766,9 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, **kwargs ): """ @@ -12815,7 +12781,7 @@ def __init__( list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2021_11_01.models.NetworkApiVersion """ super(VirtualMachineScaleSetUpdateNetworkProfile, self).__init__(**kwargs) @@ -12827,7 +12793,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -12859,16 +12825,16 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2021_11_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -12920,9 +12886,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -12954,8 +12920,8 @@ class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration(msrest.serializat ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings :ivar public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. :vartype public_ip_prefix: ~azure.mgmt.compute.v2021_11_01.models.SubResource - :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values + are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions """ @@ -12972,9 +12938,9 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - public_ip_prefix: Optional["SubResource"] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -12987,8 +12953,8 @@ def __init__( ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings :keyword public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. :paramtype public_ip_prefix: ~azure.mgmt.compute.v2021_11_01.models.SubResource - :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known + values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2021_11_01.models.DeleteOptions """ super(VirtualMachineScaleSetUpdatePublicIPAddressConfiguration, self).__init__(**kwargs) @@ -13020,9 +12986,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -13088,15 +13054,15 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, **kwargs ): @@ -13289,18 +13255,18 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - network_profile_configuration: Optional["VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, - protection_policy: Optional["VirtualMachineScaleSetVMProtectionPolicy"] = None, + protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, user_data: Optional[str] = None, **kwargs ): @@ -13475,7 +13441,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, suppress_failures: Optional[bool] = None, protected_settings_from_key_vault: Optional[Any] = None, **kwargs @@ -13545,7 +13511,7 @@ class VirtualMachineScaleSetVMExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineScaleSetVMExtension"]] = None, + value: Optional[List["_models.VirtualMachineScaleSetVMExtension"]] = None, **kwargs ): """ @@ -13841,12 +13807,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -13917,7 +13883,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -13948,7 +13914,7 @@ class VirtualMachineScaleSetVMNetworkProfileConfiguration(msrest.serialization.M def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -13995,15 +13961,14 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -14050,21 +14015,21 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, - capacity_reservation: Optional["CapacityReservationProfile"] = None, - application_profile: Optional["ApplicationProfile"] = None, - hardware_profile: Optional["VirtualMachineScaleSetHardwareProfile"] = None, + capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, + application_profile: Optional["_models.ApplicationProfile"] = None, + hardware_profile: Optional["_models.VirtualMachineScaleSetHardwareProfile"] = None, **kwargs ): """ @@ -14100,15 +14065,14 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -14275,7 +14239,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -14301,7 +14265,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype kb_id: str :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] - :ivar reboot_behavior: Describes the reboot requirements of the patch. Possible values include: + :ivar reboot_behavior: Describes the reboot requirements of the patch. Known values are: "Unknown", "NeverReboots", "AlwaysRequiresReboot", "CanRequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.compute.v2021_11_01.models.VMGuestPatchRebootBehavior @@ -14312,7 +14276,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype published_date: ~datetime.datetime :ivar last_modified_date_time: The UTC timestamp of the last update to this patch record. :vartype last_modified_date_time: ~datetime.datetime - :ivar assessment_state: Describes the availability of a given patch. Possible values include: + :ivar assessment_state: Describes the availability of a given patch. Known values are: "Unknown", "Available". :vartype assessment_state: str or ~azure.mgmt.compute.v2021_11_01.models.PatchAssessmentState """ @@ -14456,14 +14420,13 @@ class VirtualMachineUpdate(UpdateResource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2021_11_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -14570,31 +14533,31 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, platform_fault_domain: Optional[int] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, - capacity_reservation: Optional["CapacityReservationProfile"] = None, - application_profile: Optional["ApplicationProfile"] = None, + capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, + application_profile: Optional["_models.ApplicationProfile"] = None, **kwargs ): """ @@ -14656,15 +14619,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2021_11_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -14754,8 +14716,8 @@ class VMDiskSecurityProfile(msrest.serialization.Model): :ivar security_encryption_type: Specifies the EncryptionType of the managed disk. :code:`
` It is set to DiskWithVMGuestState for encryption of the managed disk along with VMGuestState blob, and VMGuestStateOnly for encryption of just the VMGuestState blob. - :code:`
`:code:`
` NOTE: It can be set for only Confidential VMs. Possible values - include: "VMGuestStateOnly", "DiskWithVMGuestState". + :code:`
`:code:`
` NOTE: It can be set for only Confidential VMs. Known values are: + "VMGuestStateOnly", "DiskWithVMGuestState". :vartype security_encryption_type: str or ~azure.mgmt.compute.v2021_11_01.models.SecurityEncryptionTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -14773,16 +14735,16 @@ class VMDiskSecurityProfile(msrest.serialization.Model): def __init__( self, *, - security_encryption_type: Optional[Union[str, "SecurityEncryptionTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + security_encryption_type: Optional[Union[str, "_models.SecurityEncryptionTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword security_encryption_type: Specifies the EncryptionType of the managed disk. :code:`
` It is set to DiskWithVMGuestState for encryption of the managed disk along with VMGuestState blob, and VMGuestStateOnly for encryption of just the VMGuestState blob. - :code:`
`:code:`
` NOTE: It can be set for only Confidential VMs. Possible values - include: "VMGuestStateOnly", "DiskWithVMGuestState". + :code:`
`:code:`
` NOTE: It can be set for only Confidential VMs. Known values are: + "VMGuestStateOnly", "DiskWithVMGuestState". :paramtype security_encryption_type: str or ~azure.mgmt.compute.v2021_11_01.models.SecurityEncryptionTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -14981,9 +14943,9 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - patch_settings: Optional["PatchSettings"] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + patch_settings: Optional["_models.PatchSettings"] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -15052,7 +15014,7 @@ class WindowsParameters(msrest.serialization.Model): def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "VMGuestPatchClassificationWindows"]]] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationWindows"]]] = None, kb_numbers_to_include: Optional[List[str]] = None, kb_numbers_to_exclude: Optional[List[str]] = None, exclude_kbs_requiring_reboot: Optional[bool] = None, @@ -15097,7 +15059,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -15112,7 +15074,7 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :vartype protocol: str or ~azure.mgmt.compute.v2021_11_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as @@ -15137,13 +15099,13 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2021_11_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/__init__.py index 8779b7a16206..e52069811132 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/__init__.py @@ -33,6 +33,9 @@ from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations from ._virtual_machine_scale_set_vm_run_commands_operations import VirtualMachineScaleSetVMRunCommandsOperations +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', 'AvailabilitySetsOperations', @@ -61,3 +64,5 @@ 'VirtualMachineRunCommandsOperations', 'VirtualMachineScaleSetVMRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_availability_sets_operations.py index f995494c208a..ddb6b0d9c6b7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,9 +123,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -157,9 +160,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +177,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -193,9 +197,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -205,20 +212,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -228,9 +233,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -241,18 +249,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -263,9 +269,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -277,51 +286,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -335,14 +340,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -354,11 +362,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -384,9 +394,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -400,14 +410,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -419,11 +432,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -462,13 +477,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -477,11 +495,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -504,7 +524,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -516,13 +536,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -531,11 +554,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -561,7 +586,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -574,13 +599,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -589,9 +617,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -600,9 +630,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -640,7 +672,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -652,13 +684,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -667,9 +702,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -678,9 +715,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -719,7 +758,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -734,13 +773,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -750,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -762,9 +806,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_capacity_reservation_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_capacity_reservation_groups_operations.py index edc4fdf63d94..86cfb727e2e4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_capacity_reservation_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_capacity_reservation_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( capacity_reservation_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservationGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( capacity_reservation_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservationGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,9 +123,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_get_request( expand: Optional[Union[str, "_models.CapacityReservationGroupInstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,20 +179,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_by_resource_group_request( expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -211,20 +218,18 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -235,9 +240,12 @@ def build_list_by_subscription_request( expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/capacityReservationGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -247,53 +255,49 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) -class CapacityReservationGroupsOperations(object): - """CapacityReservationGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CapacityReservationGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroup", + parameters: _models.CapacityReservationGroup, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details. @@ -309,14 +313,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroup') @@ -328,11 +335,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -362,9 +371,9 @@ def update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroupUpdate", + parameters: _models.CapacityReservationGroupUpdate, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. @@ -379,14 +388,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroupUpdate') @@ -398,11 +410,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -444,13 +458,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -459,11 +476,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -487,7 +506,7 @@ def get( capacity_reservation_group_name: str, expand: Optional[Union[str, "_models.CapacityReservationGroupInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation that retrieves information about a capacity reservation group. :param resource_group_name: The name of the resource group. @@ -505,13 +524,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] request = build_get_request( @@ -521,11 +543,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -552,7 +576,7 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> Iterable["_models.CapacityReservationGroupListResult"]: + ) -> Iterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -570,13 +594,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -586,9 +613,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, 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: @@ -598,9 +627,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -638,7 +669,7 @@ def list_by_subscription( self, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> Iterable["_models.CapacityReservationGroupListResult"]: + ) -> Iterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -654,13 +685,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -669,9 +703,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -680,9 +716,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_capacity_reservations_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_capacity_reservations_operations.py index 8e65deaf637c..6ea5e895611d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_capacity_reservations_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_capacity_reservations_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( capacity_reservation_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservation] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( capacity_reservation_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservationUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -168,9 +171,12 @@ def build_get_request( expand: Optional[Union[str, "_models.CapacityReservationInstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -183,20 +189,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -207,9 +211,12 @@ def build_list_by_capacity_reservation_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations") # pylint: disable=line-too-long path_format_arguments = { @@ -221,59 +228,58 @@ def build_list_by_capacity_reservation_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CapacityReservationsOperations(object): - """CapacityReservationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CapacityReservationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`capacity_reservations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> "_models.CapacityReservation": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] + ) -> _models.CapacityReservation: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] _json = self._serialize.body(parameters, 'CapacityReservation') @@ -286,11 +292,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -321,9 +329,9 @@ def begin_create_or_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> LROPoller["_models.CapacityReservation"]: + ) -> LROPoller[_models.CapacityReservation]: """The operation to create or update a capacity reservation. Please note some properties can be set only during capacity reservation creation. Please refer to https://aka.ms/CapacityReservation for more details. @@ -350,17 +358,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -368,20 +379,27 @@ def begin_create_or_update( 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('CapacityReservation', 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( @@ -399,17 +417,20 @@ def _update_initial( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> Optional["_models.CapacityReservation"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CapacityReservation"]] + ) -> Optional[_models.CapacityReservation]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.CapacityReservation]] _json = self._serialize.body(parameters, 'CapacityReservationUpdate') @@ -422,11 +443,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -455,9 +478,9 @@ def begin_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> LROPoller["_models.CapacityReservation"]: + ) -> LROPoller[_models.CapacityReservation]: """The operation to update a capacity reservation. :param resource_group_name: The name of the resource group. @@ -482,17 +505,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -500,20 +526,27 @@ def begin_update( 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('CapacityReservation', 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( @@ -533,13 +566,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements capacity_reservation_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -549,11 +585,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -600,21 +638,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -624,8 +667,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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,7 +695,7 @@ def get( capacity_reservation_name: str, expand: Optional[Union[str, "_models.CapacityReservationInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservation": + ) -> _models.CapacityReservation: """The operation that retrieves information about the capacity reservation. :param resource_group_name: The name of the resource group. @@ -665,13 +714,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.CapacityReservation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] request = build_get_request( @@ -682,11 +734,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -713,7 +767,7 @@ def list_by_capacity_reservation_group( resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> Iterable["_models.CapacityReservationListResult"]: + ) -> Iterable[_models.CapacityReservationListResult]: """Lists all of the capacity reservations in the specified capacity reservation group. Use the nextLink property in the response to get the next page of capacity reservations. @@ -728,13 +782,16 @@ def list_by_capacity_reservation_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.CapacityReservationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +801,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_capacity_reservation_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: @@ -756,9 +815,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_dedicated_host_groups_operations.py index 2572e10ef881..d5d879229283 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_dedicated_host_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,9 +123,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,20 +179,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -196,9 +200,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -209,18 +216,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -229,9 +234,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") path_format_arguments = { @@ -241,51 +249,47 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostGroupsOperations(object): - """DedicatedHostGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -301,14 +305,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -320,11 +327,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -354,9 +363,9 @@ def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -370,14 +379,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -389,11 +401,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,13 +446,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -447,11 +464,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -475,7 +494,7 @@ def get( host_group_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -491,13 +510,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -507,11 +529,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -537,7 +561,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -550,13 +574,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -565,9 +592,11 @@ def prepare_request(next_link=None): 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: @@ -576,9 +605,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -615,7 +646,7 @@ def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -626,13 +657,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -640,9 +674,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -650,9 +686,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_dedicated_hosts_operations.py index 333fe7ea3837..6db5e40d844e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHost] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -168,9 +171,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -183,20 +189,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -207,9 +211,12 @@ def build_list_by_host_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts") # pylint: disable=line-too-long path_format_arguments = { @@ -221,18 +228,16 @@ def build_list_by_host_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -244,9 +249,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -259,59 +267,58 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostsOperations(object): - """DedicatedHostsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -324,11 +331,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -359,9 +368,9 @@ def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -385,17 +394,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -403,20 +415,27 @@ def begin_create_or_update( 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('DedicatedHost', 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( @@ -434,17 +453,20 @@ def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -457,11 +479,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -488,9 +512,9 @@ def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -514,17 +538,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -532,20 +559,27 @@ def begin_update( 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('DedicatedHost', 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( @@ -565,13 +599,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements host_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -581,11 +618,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -630,21 +669,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -654,8 +698,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -676,7 +726,7 @@ def get( host_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -694,13 +744,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -711,11 +764,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -742,7 +797,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostListResult"]: + ) -> Iterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -757,13 +812,16 @@ def list_by_host_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -773,9 +831,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -785,9 +845,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -827,13 +889,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -843,11 +908,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -896,21 +963,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -920,8 +992,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_images_operations.py index fb7cc8be8743..03110e55d129 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -161,9 +164,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -211,18 +218,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +236,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -243,58 +251,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -306,11 +313,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -340,9 +349,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -363,37 +372,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -410,17 +429,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -432,11 +454,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -466,9 +490,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -489,37 +513,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -538,13 +572,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -553,11 +590,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -599,20 +638,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -622,8 +666,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -643,7 +693,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -657,13 +707,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -673,11 +726,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -703,7 +758,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -713,13 +768,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -728,9 +786,11 @@ def prepare_request(next_link=None): 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: @@ -739,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -778,7 +840,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -787,13 +849,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -801,9 +866,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -811,9 +878,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_log_analytics_operations.py index b42812fbe65b..bfb855a351ab 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_operations.py index fe95680c0394..c3163a5f9782 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_proximity_placement_groups_operations.py index 5c0b9a06b9a0..b825ab4649fc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,9 +123,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_get_request( include_colocation_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,20 +179,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if include_colocation_status is not None: - _query_parameters['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -195,9 +199,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -228,9 +233,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -241,51 +249,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -299,14 +303,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -318,11 +325,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -352,9 +361,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -368,14 +377,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -387,11 +399,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -430,13 +444,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -445,11 +462,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -473,7 +492,7 @@ def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -488,13 +507,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -504,11 +526,13 @@ def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -533,7 +557,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -543,13 +567,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +584,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -567,9 +596,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -607,7 +638,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -619,13 +650,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -634,9 +668,11 @@ def prepare_request(next_link=None): 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: @@ -645,9 +681,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_restore_point_collections_operations.py index 3b8e9c354ecf..36d53e228153 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_restore_point_collections_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_restore_point_collections_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request( resource_group_name: str, restore_point_collection_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePointCollection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request( resource_group_name: str, restore_point_collection_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePointCollectionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( restore_point_collection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -161,9 +164,12 @@ def build_get_request( expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections") # pylint: disable=line-too-long path_format_arguments = { @@ -211,18 +218,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +236,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/restorePointCollections") path_format_arguments = { @@ -243,51 +251,47 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class RestorePointCollectionsOperations(object): - """RestorePointCollectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RestorePointCollectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollection", + parameters: _models.RestorePointCollection, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. @@ -304,14 +308,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollection') @@ -323,11 +330,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -357,9 +366,9 @@ def update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollectionUpdate", + parameters: _models.RestorePointCollectionUpdate, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. @@ -373,14 +382,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollectionUpdate') @@ -392,11 +404,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -423,13 +437,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -438,11 +455,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_name=restore_point_collection_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -485,20 +504,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -508,8 +532,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -529,7 +559,7 @@ def get( restore_point_collection_name: str, expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to get the restore point collection. :param resource_group_name: The name of the resource group. @@ -544,13 +574,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] request = build_get_request( @@ -560,11 +593,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -590,7 +625,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.RestorePointCollectionListResult"]: + ) -> Iterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in a resource group. :param resource_group_name: The name of the resource group. @@ -602,13 +637,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -617,9 +655,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -628,9 +668,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -667,7 +709,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.RestorePointCollectionListResult"]: + ) -> Iterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in the subscription. Use nextLink property in the response to get the next page of restore point collections. Do this till nextLink is not null to fetch all the restore point collections. @@ -679,13 +721,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -693,9 +738,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -703,9 +750,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_restore_points_operations.py index d23ef78e8a81..7bbda19673e5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_restore_points_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_restore_points_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_request_initial( restore_point_collection_name: str, restore_point_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePoint] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,9 +82,12 @@ def build_delete_request_initial( restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -96,18 +100,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -121,9 +123,12 @@ def build_get_request( expand: Optional[Union[str, "_models.RestorePointExpandOptions"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,61 +141,60 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class RestorePointsOperations(object): - """RestorePointsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`restore_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_initial( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> "_models.RestorePoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] + ) -> _models.RestorePoint: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] _json = self._serialize.body(parameters, 'RestorePoint') @@ -203,11 +207,13 @@ def _create_initial( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -234,9 +240,9 @@ def begin_create( resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> LROPoller["_models.RestorePoint"]: + ) -> LROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. @@ -261,17 +267,20 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.RestorePoint] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] 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, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, @@ -279,20 +288,27 @@ def begin_create( 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('RestorePoint', 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( @@ -312,13 +328,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -328,11 +347,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_name=restore_point_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -377,21 +398,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -401,8 +427,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -423,7 +455,7 @@ def get( restore_point_name: str, expand: Optional[Union[str, "_models.RestorePointExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePoint": + ) -> _models.RestorePoint: """The operation to get the restore point. :param resource_group_name: The name of the resource group. @@ -440,13 +472,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] request = build_get_request( @@ -457,11 +492,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_ssh_public_keys_operations.py index c0fe2551c7ad..39bc2f4f9bc5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_ssh_public_keys_operations.py @@ -16,12 +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 .. 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,9 +31,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") path_format_arguments = { @@ -43,18 +46,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -64,9 +65,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys") # pylint: disable=line-too-long path_format_arguments = { @@ -77,18 +81,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -98,14 +100,17 @@ def build_create_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -117,20 +122,18 @@ def build_create_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -142,14 +145,17 @@ def build_update_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyUpdateResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -161,20 +167,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -187,9 +191,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +208,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -223,9 +228,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -237,18 +245,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -259,9 +265,12 @@ def build_generate_key_pair_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair") # pylint: disable=line-too-long path_format_arguments = { @@ -273,48 +282,44 @@ def build_generate_key_pair_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class SshPublicKeysOperations(object): - """SshPublicKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -325,13 +330,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -339,9 +347,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -349,9 +359,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -389,7 +401,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -402,13 +414,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -417,9 +432,11 @@ def prepare_request(next_link=None): 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: @@ -428,9 +445,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -468,9 +487,9 @@ def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -484,14 +503,17 @@ def create( :rtype: ~azure.mgmt.compute.v2021_11_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -503,11 +525,13 @@ def create( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -537,9 +561,9 @@ def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -553,14 +577,17 @@ def update( :rtype: ~azure.mgmt.compute.v2021_11_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -572,11 +599,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -615,13 +644,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -630,11 +662,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -657,7 +691,7 @@ def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -669,13 +703,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -684,11 +721,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -715,7 +754,7 @@ def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -729,13 +768,16 @@ def generate_key_pair( :rtype: ~azure.mgmt.compute.v2021_11_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -744,11 +786,13 @@ def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_usage_operations.py index 0daa86de2cc6..f7f833a39fa3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_extension_images_operations.py index ac1fe3e4d2f6..a4e828d0aed2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_extensions_operations.py index dd94c6607a65..34bf51505b22 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,9 +129,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,18 +147,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -167,9 +170,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -182,20 +188,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -208,9 +212,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -222,61 +229,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -289,11 +295,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,9 +332,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -353,17 +361,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -371,20 +382,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -402,17 +420,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -425,11 +446,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,9 +479,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -485,17 +508,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -503,20 +529,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -536,13 +569,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -552,11 +588,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -601,21 +639,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -625,8 +668,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -647,7 +696,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -663,13 +712,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -680,11 +732,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -712,7 +766,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -726,13 +780,16 @@ def list( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -742,11 +799,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_images_edge_zone_operations.py index f7a90894ef20..3ae36f29a127 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_images_edge_zone_operations.py @@ -15,6 +15,7 @@ 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 @@ -35,9 +36,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,18 +57,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -82,9 +84,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -99,24 +104,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -128,9 +131,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +149,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -165,9 +169,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -179,18 +186,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +208,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -219,42 +227,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesEdgeZoneOperations(object): - """VirtualMachineImagesEdgeZoneOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesEdgeZoneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -266,7 +270,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. @@ -286,13 +290,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -305,11 +312,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -342,7 +351,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. @@ -369,13 +378,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -390,11 +402,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -422,7 +436,7 @@ def list_offers( edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. @@ -437,13 +451,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -453,11 +470,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -484,7 +503,7 @@ def list_publishers( location: str, edge_zone: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. @@ -496,13 +515,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -511,11 +533,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -544,7 +568,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. @@ -561,13 +585,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -578,11 +605,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_images_operations.py index 6816673bd35e..4a8e61089718 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,42 +217,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -255,7 +259,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -273,13 +277,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -291,11 +298,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -327,7 +336,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -350,13 +359,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -370,11 +382,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -401,7 +415,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -413,13 +427,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -428,11 +445,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,7 +477,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -468,13 +487,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -482,11 +504,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -514,7 +538,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -528,13 +552,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -544,11 +571,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_run_commands_operations.py index 4f606f1c303b..f126197fee0e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -69,9 +70,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -83,18 +87,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -105,14 +107,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -125,20 +130,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -151,14 +154,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,20 +177,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -198,9 +202,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -213,18 +220,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -238,9 +243,12 @@ def build_get_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -253,20 +261,18 @@ def build_get_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -279,9 +285,12 @@ def build_list_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -293,51 +302,47 @@ def build_list_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -349,13 +354,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +372,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -375,9 +385,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -416,7 +428,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -428,13 +440,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -443,11 +458,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -473,18 +490,21 @@ def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -497,11 +517,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,11 +554,11 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -548,7 +570,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -565,16 +587,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -582,20 +607,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -613,18 +645,21 @@ def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -637,11 +672,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -668,11 +705,11 @@ def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -683,7 +720,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -700,16 +737,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -717,20 +757,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -750,13 +797,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -766,11 +816,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,21 +867,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -839,8 +896,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -861,7 +924,7 @@ def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -877,13 +940,16 @@ def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -894,11 +960,13 @@ def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -926,7 +994,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -942,13 +1010,16 @@ def list_by_virtual_machine( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -959,9 +1030,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -972,9 +1045,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_extensions_operations.py index abfc03b12e5a..3a355c4a2f20 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -168,9 +171,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -183,20 +189,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -207,9 +211,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -221,59 +228,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -286,11 +292,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -321,9 +329,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -351,17 +359,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -369,20 +380,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -400,17 +418,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -423,11 +444,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,9 +481,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -487,17 +510,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -505,20 +531,27 @@ def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -538,13 +571,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -554,11 +590,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -603,21 +641,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -627,8 +670,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -649,7 +698,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -665,13 +714,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -682,11 +734,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -713,7 +767,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -727,13 +781,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -743,9 +800,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -755,9 +814,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index ffd6cdda70e7..8c5ce3916ad5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,9 +34,12 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +51,16 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -69,9 +71,12 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -83,18 +88,16 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -105,9 +108,12 @@ def build_start_extension_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -119,18 +125,16 @@ def build_start_extension_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -141,9 +145,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -155,42 +162,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -198,13 +201,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -213,11 +219,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -259,20 +267,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -282,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -302,13 +321,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -317,11 +339,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -365,20 +389,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -388,8 +417,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -408,13 +443,16 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -423,11 +461,13 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -471,20 +511,25 @@ def begin_start_extension_upgrade( # pylint: disable=inconsistent-return-statem :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_extension_upgrade_initial( + raw_result = self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -494,8 +539,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -514,7 +565,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -526,13 +577,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -541,11 +595,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py index 11cbf836579b..345b504fc5e5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -56,20 +59,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -83,14 +84,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -104,20 +108,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -132,9 +134,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -148,18 +153,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -174,9 +177,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -190,20 +196,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -217,9 +221,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -232,44 +239,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMExtensionsOperations(object): - """VirtualMachineScaleSetVMExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -277,17 +280,20 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -301,11 +307,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -368,17 +376,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -387,20 +398,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -419,17 +437,20 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -443,11 +464,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -475,9 +498,9 @@ def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -506,17 +529,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -525,20 +551,27 @@ def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -559,13 +592,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -576,11 +612,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -628,22 +666,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -653,8 +696,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -676,7 +725,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -694,13 +743,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -712,11 +764,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -745,7 +799,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -761,13 +815,16 @@ def list( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -778,11 +835,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index e1d4b722239a..425b00311671 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -133,9 +135,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -149,18 +154,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -175,9 +178,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -191,20 +197,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -218,9 +222,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -233,44 +240,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMRunCommandsOperations(object): - """VirtualMachineScaleSetVMRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -278,18 +281,21 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -303,11 +309,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -339,11 +347,11 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -356,7 +364,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -373,16 +381,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -423,18 +441,21 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,11 +503,11 @@ def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -497,7 +520,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -514,16 +537,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -532,20 +558,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -566,13 +599,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -583,11 +619,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,22 +673,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -660,8 +703,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -683,7 +732,7 @@ def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -701,13 +750,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_request( @@ -719,11 +771,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -752,7 +806,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -770,13 +824,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -788,9 +845,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -802,9 +861,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_vms_operations.py index f4ddaebcfcd8..2f2cd1a6f521 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_reimage_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,9 +83,12 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -97,18 +101,16 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -120,9 +122,12 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -157,14 +160,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +183,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -206,9 +210,12 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -221,20 +228,18 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -248,9 +253,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -263,20 +271,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -288,9 +294,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -303,18 +312,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -329,9 +336,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -343,24 +353,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -374,9 +382,12 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -389,20 +400,18 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -414,9 +423,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -429,18 +441,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -452,9 +462,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -467,18 +480,16 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -490,9 +501,12 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -505,18 +519,16 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -530,9 +542,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -545,20 +560,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -570,9 +583,12 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -585,18 +601,16 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -608,9 +622,12 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -623,18 +640,16 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -645,14 +660,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -665,63 +683,62 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -737,11 +754,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -764,7 +783,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -791,17 +810,20 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -809,6 +831,8 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -818,8 +842,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -839,13 +869,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -855,11 +888,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -905,21 +940,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -929,8 +969,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -950,13 +996,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -966,11 +1015,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1017,21 +1068,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1041,8 +1097,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1060,17 +1122,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -1083,11 +1148,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1118,9 +1185,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1146,17 +1213,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1164,20 +1234,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1198,13 +1275,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1215,11 +1295,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1268,22 +1350,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1293,8 +1380,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1315,7 +1408,7 @@ def get( instance_id: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1333,13 +1426,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1350,11 +1446,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1382,7 +1480,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1396,13 +1494,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1412,11 +1513,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1446,7 +1549,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1470,13 +1573,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1489,9 +1595,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1504,9 +1612,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1547,13 +1657,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1564,11 +1677,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1620,22 +1735,27 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1645,8 +1765,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1666,13 +1792,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1682,11 +1811,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1731,21 +1862,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1755,8 +1891,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1776,13 +1918,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1792,11 +1937,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1841,21 +1988,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1865,8 +2017,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1886,13 +2044,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1902,11 +2063,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1952,21 +2115,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1976,8 +2144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1998,7 +2172,7 @@ def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -2017,13 +2191,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -2034,11 +2211,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2066,13 +2245,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2082,11 +2264,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2131,21 +2315,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2155,8 +2344,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2190,13 +2385,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2206,11 +2404,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2232,18 +2432,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2256,11 +2459,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2289,11 +2494,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2304,7 +2509,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_11_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2320,16 +2525,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2337,20 +2545,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_sets_operations.py index 3648c9d721d2..a3f86886893a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -159,9 +162,12 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,20 +179,18 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -199,9 +203,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -213,20 +220,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -236,14 +241,17 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -255,20 +263,18 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -280,15 +286,18 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -300,22 +309,20 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -328,9 +335,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -342,18 +352,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -363,9 +371,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -376,18 +387,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -396,9 +405,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -408,18 +420,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -430,9 +440,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -444,18 +457,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -466,9 +477,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -480,18 +494,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -501,15 +513,18 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -521,22 +536,20 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -548,14 +561,17 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -567,20 +583,18 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -592,14 +606,17 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -611,20 +628,18 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -636,14 +651,17 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -655,20 +673,18 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -680,14 +696,17 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -699,20 +718,18 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -724,14 +741,17 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -743,20 +763,18 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -768,14 +786,17 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -787,20 +808,18 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -812,14 +831,17 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -831,20 +853,18 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -861,9 +881,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( placement_group_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -875,23 +898,21 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') if zone is not None: - _query_parameters['zone'] = _SERIALIZER.query("zone", zone, 'str') + _params['zone'] = _SERIALIZER.query("zone", zone, 'str') if placement_group_id is not None: - _query_parameters['placementGroupId'] = _SERIALIZER.query("placement_group_id", placement_group_id, 'str') + _params['placementGroupId'] = _SERIALIZER.query("placement_group_id", placement_group_id, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -901,14 +922,17 @@ def build_convert_to_single_placement_group_request( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VMScaleSetConvertToSinglePlacementGroupInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup") # pylint: disable=line-too-long path_format_arguments = { @@ -920,20 +944,18 @@ def build_convert_to_single_placement_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -945,14 +967,17 @@ def build_set_orchestration_service_state_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.OrchestrationServiceStateInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState") # pylint: disable=line-too-long path_format_arguments = { @@ -964,53 +989,49 @@ def build_set_orchestration_service_state_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. @@ -1022,13 +1043,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1037,9 +1061,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -1048,9 +1074,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1087,17 +1115,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -1109,11 +1140,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1143,9 +1176,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1168,37 +1201,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1215,17 +1258,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -1237,11 +1283,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1267,9 +1315,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1292,37 +1340,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1342,13 +1400,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1358,11 +1419,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1408,21 +1471,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1432,8 +1500,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1453,7 +1527,7 @@ def get( vm_scale_set_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1469,13 +1543,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1485,11 +1562,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1514,17 +1593,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1539,11 +1621,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1565,7 +1649,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1592,23 +1676,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1618,8 +1707,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1636,18 +1731,21 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1660,11 +1758,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements json=_json, force_deletion=force_deletion, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1686,7 +1786,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: @@ -1714,17 +1814,20 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, @@ -1732,6 +1835,8 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1741,8 +1846,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1761,7 +1872,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1773,13 +1884,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1788,11 +1902,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1818,7 +1934,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1830,13 +1946,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1845,9 +1964,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1856,9 +1977,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1895,7 +2018,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1907,13 +2030,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1921,9 +2047,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1931,9 +2059,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1972,7 +2102,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1987,13 +2117,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2003,9 +2136,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2015,9 +2150,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2056,7 +2193,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -2070,13 +2207,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2086,9 +2226,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2098,9 +2240,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2138,17 +2282,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2164,11 +2311,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2191,7 +2340,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -2222,17 +2371,20 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -2240,6 +2392,8 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2249,8 +2403,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2267,17 +2427,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2292,11 +2455,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2318,7 +2483,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2343,23 +2508,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2369,8 +2539,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2387,17 +2563,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2412,11 +2591,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2438,7 +2619,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2463,23 +2644,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2489,8 +2675,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2507,17 +2699,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2532,11 +2727,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2558,7 +2755,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2584,23 +2781,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2610,8 +2812,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2628,17 +2836,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2653,11 +2864,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2679,7 +2892,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2707,23 +2920,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2733,8 +2951,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2751,17 +2975,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2773,11 +3000,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2799,7 +3028,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2823,23 +3052,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2849,8 +3083,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2867,17 +3107,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -2892,11 +3135,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2918,7 +3163,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -2944,23 +3189,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2970,8 +3220,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2988,17 +3244,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -3013,11 +3272,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3039,7 +3300,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -3065,23 +3326,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -3091,8 +3357,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -3114,7 +3386,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( zone: Optional[str] = None, placement_group_id: Optional[str] = None, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -3136,13 +3408,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -3154,11 +3429,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( zone=zone, placement_group_id=placement_group_id, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3184,7 +3461,7 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -3201,14 +3478,17 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st :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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -3220,11 +3500,13 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3245,17 +3527,20 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] _json = self._serialize.body(parameters, 'OrchestrationServiceStateInput') @@ -3267,11 +3552,13 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3293,7 +3580,7 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> LROPoller[None]: """Changes ServiceState property for a given service. @@ -3316,23 +3603,28 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._set_orchestration_service_state_initial( + raw_result = self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -3342,8 +3634,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_sizes_operations.py index 2eef98032797..165d0e5b8d83 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -99,13 +99,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machines_operations.py index 5875364c3d31..eb2f0d8773e4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_11_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -203,9 +207,12 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -217,20 +224,18 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -243,9 +248,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -257,20 +265,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -281,9 +287,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -295,18 +304,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -317,9 +324,12 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -331,18 +341,16 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -355,9 +363,12 @@ def build_deallocate_request_initial( hibernate: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -369,20 +380,18 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if hibernate is not None: - _query_parameters['hibernate'] = _SERIALIZER.query("hibernate", hibernate, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['hibernate'] = _SERIALIZER.query("hibernate", hibernate, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -393,9 +402,12 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -407,18 +419,16 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -430,9 +440,12 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -443,20 +456,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -468,9 +479,12 @@ def build_list_all_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -480,22 +494,20 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 status_only is not None: - _query_parameters['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') + _params['statusOnly'] = _SERIALIZER.query("status_only", status_only, '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, + params=_params, + headers=_headers, **kwargs ) @@ -506,9 +518,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -520,18 +535,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -544,9 +557,12 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -558,20 +574,18 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -582,9 +596,12 @@ def build_reapply_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply") # pylint: disable=line-too-long path_format_arguments = { @@ -596,18 +613,16 @@ def build_reapply_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -618,9 +633,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -632,18 +650,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -654,9 +670,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -668,18 +687,16 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -690,9 +707,12 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -704,18 +724,16 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -725,14 +743,17 @@ def build_reimage_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -744,20 +765,18 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -772,9 +791,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -786,20 +808,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -810,9 +830,12 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -824,18 +847,16 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -846,9 +867,12 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -860,18 +884,16 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -882,9 +904,12 @@ def build_assess_patches_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -896,18 +921,16 @@ def build_assess_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -917,14 +940,17 @@ def build_install_patches_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineInstallPatchesParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -936,20 +962,18 @@ def build_install_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -961,14 +985,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -980,53 +1007,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2021_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.compute.v2021_11_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -1038,13 +1061,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1053,9 +1079,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -1064,9 +1092,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1103,17 +1133,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -1125,11 +1158,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1157,9 +1192,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -1183,37 +1218,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -1230,17 +1275,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -1252,11 +1300,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1286,9 +1336,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -1311,37 +1361,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1358,17 +1418,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1380,11 +1443,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1410,9 +1475,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1434,37 +1499,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1484,13 +1559,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1500,11 +1578,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1550,21 +1630,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1574,8 +1659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1595,7 +1686,7 @@ def get( vm_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1613,13 +1704,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1629,11 +1723,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1660,7 +1756,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1672,13 +1768,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2021_11_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1687,11 +1786,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1718,13 +1819,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1733,11 +1837,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1780,20 +1886,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1803,8 +1914,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1824,13 +1941,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements hibernate: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -1840,11 +1960,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, hibernate=hibernate, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1891,21 +2013,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, hibernate=hibernate, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1915,8 +2042,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1952,13 +2085,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1967,11 +2103,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1994,7 +2132,7 @@ def list( resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -2012,13 +2150,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2028,9 +2169,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -2040,9 +2183,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -2081,7 +2226,7 @@ def list_all( status_only: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -2100,13 +2245,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2116,9 +2264,11 @@ def prepare_request(next_link=None): status_only=status_only, filter=filter, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2128,9 +2278,11 @@ def prepare_request(next_link=None): status_only=status_only, 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 @@ -2169,7 +2321,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -2184,13 +2336,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2200,9 +2355,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2212,9 +2369,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2254,13 +2413,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -2270,11 +2432,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2322,21 +2486,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2346,8 +2515,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2366,13 +2541,16 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -2381,11 +2559,13 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2427,20 +2607,25 @@ def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._reapply_initial( + raw_result = self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2450,8 +2635,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2470,13 +2661,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2485,11 +2679,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2531,20 +2727,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2554,8 +2755,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2574,13 +2781,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2589,11 +2799,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2635,20 +2847,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2658,8 +2875,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2678,13 +2901,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2693,11 +2919,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2739,20 +2967,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2762,8 +2995,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2780,17 +3019,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -2805,11 +3047,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2831,7 +3075,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -2855,23 +3099,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] cls = kwargs.pop('cls', None) # type: ClsType[None] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -2881,8 +3130,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2902,7 +3157,7 @@ def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -2918,13 +3173,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2021_11_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -2934,11 +3192,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2965,13 +3225,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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', "2021-11-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2980,11 +3243,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3026,20 +3291,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -3049,8 +3319,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -3081,13 +3357,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -3096,11 +3375,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3122,14 +3403,17 @@ def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -3138,11 +3422,13 @@ def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3171,7 +3457,7 @@ def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -3192,34 +3478,44 @@ def begin_assess_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -3236,17 +3532,20 @@ def _install_patches_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineInstallPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineInstallPatchesResult"]] + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineInstallPatchesResult]] _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') @@ -3258,11 +3557,13 @@ def _install_patches_initial( content_type=content_type, json=_json, template_url=self._install_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3290,9 +3591,9 @@ def begin_install_patches( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineInstallPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. @@ -3316,37 +3617,47 @@ def begin_install_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.VirtualMachineInstallPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstallPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstallPatchesResult"] 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._install_patches_initial( + raw_result = self._install_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineInstallPatchesResult', 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( @@ -3363,18 +3674,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -3386,11 +3700,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3418,11 +3734,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -3431,7 +3747,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2021_11_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -3447,36 +3763,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_11_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-11-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/_compute_management_client.py index ea2e2c134e29..7155e682be78 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/_compute_management_client.py @@ -65,11 +65,21 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_restore_point = DiskRestorePointOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/_compute_management_client.py index a9d9f64154f7..ec415f70e39a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/_compute_management_client.py @@ -65,11 +65,21 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_restore_point = DiskRestorePointOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/__init__.py index c3e7f3bd4f2e..332fb79d2c68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/__init__.py @@ -12,6 +12,9 @@ from ._disk_accesses_operations import DiskAccessesOperations from ._disk_restore_point_operations import DiskRestorePointOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', @@ -19,3 +22,5 @@ 'DiskAccessesOperations', 'DiskRestorePointOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disk_accesses_operations.py index b733129eae9d..937c574096fd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskAccessesOperations: - """DiskAccessesOperations async operations. - - You 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.compute.v2021_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.compute.v2021_12_01.aio.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_12_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_12_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_12_01.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -340,11 +372,13 @@ async def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -626,7 +690,7 @@ async def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -640,13 +704,16 @@ async def get_private_link_resources( :rtype: ~azure.mgmt.compute.v2021_12_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', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -655,11 +722,13 @@ async def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -685,17 +754,20 @@ async def _update_a_private_endpoint_connection_initial( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.PrivateEndpointConnection] _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') @@ -708,11 +780,13 @@ async def _update_a_private_endpoint_connection_initial( content_type=content_type, json=_json, template_url=self._update_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -743,9 +817,9 @@ async def begin_update_a_private_endpoint_connection( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection under disk access resource, this can't be used to create a new private endpoint connection. @@ -775,17 +849,20 @@ async def begin_update_a_private_endpoint_connection( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_12_01.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.PrivateEndpointConnection] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_a_private_endpoint_connection_initial( + raw_result = await self._update_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -793,20 +870,27 @@ async def begin_update_a_private_endpoint_connection( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -826,7 +910,7 @@ async def get_a_private_endpoint_connection( disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about a private endpoint connection under a disk access resource. :param resource_group_name: The name of the resource group. @@ -842,13 +926,16 @@ async def get_a_private_endpoint_connection( :rtype: ~azure.mgmt.compute.v2021_12_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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_a_private_endpoint_connection_request( @@ -858,11 +945,13 @@ async def get_a_private_endpoint_connection( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get_a_private_endpoint_connection.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -890,13 +979,16 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inco private_endpoint_connection_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', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_a_private_endpoint_connection_request_initial( @@ -906,11 +998,13 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inco private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -957,21 +1051,26 @@ async def begin_delete_a_private_endpoint_connection( # pylint: disable=inconsi :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_a_private_endpoint_connection_initial( + raw_result = await self._delete_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -981,8 +1080,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1001,7 +1106,7 @@ def list_private_endpoint_connections( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List information about private endpoint connections under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1017,13 +1122,16 @@ def list_private_endpoint_connections( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_12_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - 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: @@ -1033,9 +1141,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=self.list_private_endpoint_connections.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1045,9 +1155,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disk_encryption_sets_operations.py index b01ebc1efca0..bb0ffb447f69 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskEncryptionSetsOperations: - """DiskEncryptionSetsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_12_01.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -238,9 +257,9 @@ async def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -266,37 +285,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -315,7 +344,7 @@ async def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -329,13 +358,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -344,11 +376,13 @@ async def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -375,13 +409,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -390,11 +427,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,20 +477,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -461,8 +505,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -480,7 +530,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -492,13 +542,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -507,9 +560,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -518,9 +573,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -557,7 +614,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -567,13 +624,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -581,9 +641,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -591,9 +653,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -632,7 +696,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceUriList"]: + ) -> AsyncIterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -647,13 +711,16 @@ def list_associated_resources( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_12_01.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -663,9 +730,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_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,9 +744,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disk_restore_point_operations.py index e25bfa641f6f..2605960cc21a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disk_restore_point_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskRestorePointOperations: - """DiskRestorePointOperations async operations. - - You 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.compute.v2021_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.compute.v2021_12_01.aio.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -55,7 +54,7 @@ async def get( vm_restore_point_name: str, disk_restore_point_name: str, **kwargs: Any - ) -> "_models.DiskRestorePoint": + ) -> _models.DiskRestorePoint: """Get disk restorePoint resource. :param resource_group_name: The name of the resource group. @@ -73,13 +72,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_12_01.models.DiskRestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePoint] request = build_get_request( @@ -90,11 +92,13 @@ async def get( disk_restore_point_name=disk_restore_point_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -122,7 +126,7 @@ def list_by_restore_point( restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskRestorePointList"]: + ) -> AsyncIterable[_models.DiskRestorePointList]: """Lists diskRestorePoints under a vmRestorePoint. :param resource_group_name: The name of the resource group. @@ -140,13 +144,16 @@ def list_by_restore_point( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskRestorePointList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePointList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePointList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -157,9 +164,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=self.list_by_restore_point.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -170,9 +179,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -211,17 +222,20 @@ async def _grant_access_initial( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -235,11 +249,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -269,9 +285,9 @@ async def begin_grant_access( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a diskRestorePoint. :param resource_group_name: The name of the resource group. @@ -300,17 +316,20 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_12_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, @@ -319,20 +338,27 @@ async def begin_grant_access( 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('AccessUri', 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( @@ -353,13 +379,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_restore_point_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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -370,11 +399,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_restore_point_name=disk_restore_point_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -424,22 +455,27 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, disk_restore_point_name=disk_restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -449,8 +485,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disks_operations.py index bb4273d016d7..8195f470fd0c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2021_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.compute.v2021_12_01.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_12_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_12_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_12_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_12_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_snapshots_operations.py index 41f568cf72c2..52cb9976b62e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2021_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.compute.v2021_12_01.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_12_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_12_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2021_12_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_12_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2021_12_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2021_12_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/__init__.py index 6cc54759c08b..42b3357b955c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/__init__.py @@ -74,7 +74,9 @@ PublicNetworkAccess, SnapshotStorageAccountTypes, ) - +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__ = [ 'AccessUri', 'ApiError', @@ -141,3 +143,5 @@ 'PublicNetworkAccess', 'SnapshotStorageAccountTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/_compute_management_client_enums.py index cc66bea62b9a..be49747f5363 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/_compute_management_client_enums.py @@ -7,24 +7,23 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" WRITE = "Write" -class Architecture(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): """CPU architecture supported by an OS disk. """ X64 = "x64" ARM64 = "Arm64" -class DataAccessAuthMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DataAccessAuthMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Additional authentication requirements when exporting or uploading to a disk or snapshot. """ @@ -35,7 +34,7 @@ class DataAccessAuthMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: No additional authentication would be performed when accessing export/upload URL. NONE = "None" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -68,7 +67,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: disk and upload using write token in both disk and VM guest state. UPLOAD_PREPARED_SECURE = "UploadPreparedSecure" -class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted resources @@ -78,7 +77,7 @@ class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, SYSTEM_ASSIGNED = "SystemAssigned" NONE = "None" -class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -91,7 +90,7 @@ class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Confidential VM supported disk and VM guest state would be encrypted with customer managed key. CONFIDENTIAL_VM_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVmEncryptedWithCustomerKey" -class DiskSecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskSecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the SecurityType of the VM. Applicable for OS disks only. """ @@ -107,7 +106,7 @@ class DiskSecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: managed key. CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVM_DiskEncryptedWithCustomerKey" -class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible state of the disk. """ @@ -128,7 +127,7 @@ class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: A disk is created for upload and a write token has been issued for uploading to it. ACTIVE_UPLOAD = "ActiveUpload" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -149,7 +148,7 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: and dev/test that need storage resiliency against zone failures. STANDARD_SSD_ZRS = "StandardSSD_ZRS" -class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -163,20 +162,20 @@ class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the other key is Platform managed. ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Policy for accessing the disk via network. """ @@ -187,14 +186,14 @@ class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The disk cannot be exported. DENY_ALL = "DenyAll" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -203,7 +202,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. """ @@ -211,7 +210,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Policy for controlling export on the disk. """ @@ -224,7 +223,7 @@ class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate. DISABLED = "Disabled" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/_models_py3.py index cc83ccf2deaf..9b13b3c5b9d9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -71,8 +73,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -144,9 +146,9 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", - "CopyStart", "ImportSecure", "UploadPreparedSecure". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart", + "ImportSecure", "UploadPreparedSecure". :vartype create_option: str or ~azure.mgmt.compute.v2021_12_01.models.DiskCreateOption :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -199,10 +201,10 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, - gallery_image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, + gallery_image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, upload_size_bytes: Optional[int] = None, @@ -212,7 +214,7 @@ def __init__( ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart", "ImportSecure", "UploadPreparedSecure". :paramtype create_option: str or ~azure.mgmt.compute.v2021_12_01.models.DiskCreateOption :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager @@ -342,10 +344,10 @@ class Disk(Resource): :vartype extended_location: ~azure.mgmt.compute.v2021_12_01.models.ExtendedLocation :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_12_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_12_01.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: @@ -386,7 +388,7 @@ class Disk(Resource): mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. :vartype disk_m_bps_read_only: long - :ivar disk_state: The state of the disk. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2021_12_01.models.DiskState :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed @@ -398,8 +400,8 @@ class Disk(Resource): :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should be set to a value greater than one for disks to allow attaching them to multiple VMs. :vartype share_info: list[~azure.mgmt.compute.v2021_12_01.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_12_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -421,12 +423,12 @@ class Disk(Resource): :ivar completion_percent: Percentage complete for the background copy when a resource is created via the CopyStart operation. :vartype completion_percent: float - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_12_01.models.PublicNetworkAccess :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :vartype data_access_auth_mode: str or ~azure.mgmt.compute.v2021_12_01.models.DataAccessAuthMode """ @@ -494,31 +496,31 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, - creation_data: Optional["CreationData"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, supports_hibernation: Optional[bool] = None, - security_profile: Optional["DiskSecurityProfile"] = None, + security_profile: Optional["_models.DiskSecurityProfile"] = None, completion_percent: Optional[float] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "DataAccessAuthMode"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, **kwargs ): """ @@ -534,10 +536,10 @@ def __init__( :keyword extended_location: The extended location where the disk will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2021_12_01.models.ExtendedLocation - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_12_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_12_01.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: @@ -578,8 +580,8 @@ def __init__( :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_12_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -599,12 +601,12 @@ def __init__( :keyword completion_percent: Percentage complete for the background copy when a resource is created via the CopyStart operation. :paramtype completion_percent: float - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_12_01.models.PublicNetworkAccess :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + uploading to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.v2021_12_01.models.DataAccessAuthMode """ @@ -702,7 +704,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, **kwargs ): """ @@ -745,7 +747,7 @@ class DiskAccessList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskAccess"], + value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs ): @@ -806,8 +808,8 @@ class DiskEncryptionSet(Resource): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2021_12_01.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", "ConfidentialVmEncryptedWithCustomerKey". :vartype encryption_type: str or ~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSetType :ivar active_key: The key vault key which is currently used by this disk encryption set. @@ -862,9 +864,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyForDiskEncryptionSet"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, rotation_to_latest_key_version_enabled: Optional[bool] = None, **kwargs ): @@ -876,8 +878,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2021_12_01.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", "ConfidentialVmEncryptedWithCustomerKey". :paramtype encryption_type: str or ~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSetType :keyword active_key: The key vault key which is currently used by this disk encryption set. @@ -921,7 +923,7 @@ class DiskEncryptionSetList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskEncryptionSet"], + value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs ): @@ -945,8 +947,8 @@ class DiskEncryptionSetUpdate(msrest.serialization.Model): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2021_12_01.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", "ConfidentialVmEncryptedWithCustomerKey". :vartype encryption_type: str or ~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSetType :ivar active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and @@ -969,9 +971,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyForDiskEncryptionSet"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, rotation_to_latest_key_version_enabled: Optional[bool] = None, **kwargs ): @@ -981,8 +983,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2021_12_01.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", "ConfidentialVmEncryptedWithCustomerKey". :paramtype encryption_type: str or ~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSetType :keyword active_key: Key Vault Key Url to be used for server side encryption of Managed Disks @@ -1024,7 +1026,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -1092,10 +1094,10 @@ class DiskRestorePoint(ProxyOnlyResource): :vartype time_created: ~datetime.datetime :ivar source_resource_id: arm id of source disk or source disk restore point. :vartype source_resource_id: str - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_12_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_12_01.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. @@ -1112,12 +1114,12 @@ class DiskRestorePoint(ProxyOnlyResource): :vartype encryption: ~azure.mgmt.compute.v2021_12_01.models.Encryption :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. :vartype supports_hibernation: bool - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_12_01.models.NetworkAccessPolicy - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_12_01.models.PublicNetworkAccess :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -1172,19 +1174,19 @@ class DiskRestorePoint(ProxyOnlyResource): def __init__( self, *, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, supports_hibernation: Optional[bool] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, disk_access_id: Optional[str] = None, completion_percent: Optional[float] = None, **kwargs ): """ :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_12_01.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. @@ -1194,12 +1196,12 @@ def __init__( :paramtype supported_capabilities: ~azure.mgmt.compute.v2021_12_01.models.SupportedCapabilities :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. :paramtype supports_hibernation: bool - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_12_01.models.NetworkAccessPolicy - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_12_01.models.PublicNetworkAccess :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -1252,7 +1254,7 @@ class DiskRestorePointList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskRestorePoint"], + value: List["_models.DiskRestorePoint"], next_link: Optional[str] = None, **kwargs ): @@ -1271,9 +1273,8 @@ def __init__( class DiskSecurityProfile(msrest.serialization.Model): """Contains the security related information for the resource. - :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Possible values include: "TrustedLaunch", - "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", + :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. Known + values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithCustomerKey". :vartype security_type: str or ~azure.mgmt.compute.v2021_12_01.models.DiskSecurityTypes :ivar secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to @@ -1289,14 +1290,13 @@ class DiskSecurityProfile(msrest.serialization.Model): def __init__( self, *, - security_type: Optional[Union[str, "DiskSecurityTypes"]] = None, + security_type: Optional[Union[str, "_models.DiskSecurityTypes"]] = None, secure_vm_disk_encryption_set_id: Optional[str] = None, **kwargs ): """ :keyword security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Possible values include: "TrustedLaunch", - "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", + Known values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithCustomerKey". :paramtype security_type: str or ~azure.mgmt.compute.v2021_12_01.models.DiskSecurityTypes :keyword secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to @@ -1313,8 +1313,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :vartype name: str or ~azure.mgmt.compute.v2021_12_01.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -1332,11 +1332,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2021_12_01.models.DiskStorageAccountTypes """ @@ -1355,7 +1355,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, or StandardSSD_ZRS. :vartype sku: ~azure.mgmt.compute.v2021_12_01.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_12_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1386,8 +1386,8 @@ class DiskUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2021_12_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_12_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -1408,12 +1408,12 @@ class DiskUpdate(msrest.serialization.Model): ~azure.mgmt.compute.v2021_12_01.models.PropertyUpdatesInProgress :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_12_01.models.PublicNetworkAccess :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :vartype data_access_auth_mode: str or ~azure.mgmt.compute.v2021_12_01.models.DataAccessAuthMode """ @@ -1450,25 +1450,25 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, max_shares: Optional[int] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, - purchase_plan: Optional["PurchasePlan"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "DataAccessAuthMode"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, **kwargs ): """ @@ -1477,7 +1477,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, or StandardSSD_ZRS. :paramtype sku: ~azure.mgmt.compute.v2021_12_01.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_12_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1508,8 +1508,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2021_12_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_12_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -1528,12 +1528,12 @@ def __init__( :paramtype supported_capabilities: ~azure.mgmt.compute.v2021_12_01.models.SupportedCapabilities :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_12_01.models.PublicNetworkAccess :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + uploading to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.v2021_12_01.models.DataAccessAuthMode """ @@ -1567,7 +1567,7 @@ class Encryption(msrest.serialization.Model): :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Possible values include: + :ivar type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype type: str or ~azure.mgmt.compute.v2021_12_01.models.EncryptionType @@ -1582,14 +1582,14 @@ def __init__( self, *, disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "EncryptionType"]] = None, + type: Optional[Union[str, "_models.EncryptionType"]] = None, **kwargs ): """ :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Possible values include: + :keyword type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype type: str or ~azure.mgmt.compute.v2021_12_01.models.EncryptionType @@ -1607,7 +1607,7 @@ class EncryptionSetIdentity(msrest.serialization.Model): :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted - resources to lose access to the keys. Possible values include: "SystemAssigned", "None". + resources to lose access to the keys. Known values are: "SystemAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSetIdentityType :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a @@ -1633,15 +1633,14 @@ class EncryptionSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "DiskEncryptionSetIdentityType"]] = None, + type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, **kwargs ): """ :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the - encrypted resources to lose access to the keys. Possible values include: "SystemAssigned", - "None". + encrypted resources to lose access to the keys. Known values are: "SystemAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSetIdentityType """ super(EncryptionSetIdentity, self).__init__(**kwargs) @@ -1683,7 +1682,7 @@ def __init__( self, *, enabled: bool, - encryption_settings: Optional[List["EncryptionSettingsElement"]] = None, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, encryption_settings_version: Optional[str] = None, **kwargs ): @@ -1725,8 +1724,8 @@ class EncryptionSettingsElement(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -1747,7 +1746,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.compute.v2021_12_01.models.ExtendedLocationTypes """ @@ -1760,13 +1759,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.compute.v2021_12_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -1779,7 +1778,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read", "Write". + :ivar access: Required. Known values are: "None", "Read", "Write". :vartype access: str or ~azure.mgmt.compute.v2021_12_01.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -1802,13 +1801,13 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, get_secure_vm_guest_state_sas: Optional[bool] = None, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read", "Write". + :keyword access: Required. Known values are: "None", "Read", "Write". :paramtype access: str or ~azure.mgmt.compute.v2021_12_01.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -1923,7 +1922,7 @@ def __init__( self, *, key_url: str, - source_vault: Optional["SourceVault"] = None, + source_vault: Optional["_models.SourceVault"] = None, **kwargs ): """ @@ -1964,7 +1963,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -2003,7 +2002,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -2063,7 +2062,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype private_link_service_connection_state: ~azure.mgmt.compute.v2021_12_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.compute.v2021_12_01.models.PrivateEndpointConnectionProvisioningState """ @@ -2088,7 +2087,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): def __init__( self, *, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -2124,7 +2123,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2209,7 +2208,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -2224,7 +2223,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.compute.v2021_12_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -2243,14 +2242,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, actions_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.compute.v2021_12_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -2445,10 +2444,10 @@ class Snapshot(Resource): :vartype extended_location: ~azure.mgmt.compute.v2021_12_01.models.ExtendedLocation :ivar time_created: The time when the snapshot was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_12_01.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2021_12_01.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. @@ -2466,7 +2465,7 @@ class Snapshot(Resource): :vartype disk_size_gb: int :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. :vartype disk_size_bytes: long - :ivar disk_state: The state of the snapshot. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the snapshot. Known values are: "Unattached", "Attached", "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2021_12_01.models.DiskState :ivar unique_id: Unique Guid identifying the resource. @@ -2483,8 +2482,8 @@ class Snapshot(Resource): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2021_12_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_12_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -2493,15 +2492,15 @@ class Snapshot(Resource): :vartype security_profile: ~azure.mgmt.compute.v2021_12_01.models.DiskSecurityProfile :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_12_01.models.PublicNetworkAccess :ivar completion_percent: Percentage complete for the background copy when a resource is created via the CopyStart operation. :vartype completion_percent: float :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :vartype data_access_auth_mode: str or ~azure.mgmt.compute.v2021_12_01.models.DataAccessAuthMode """ @@ -2556,24 +2555,24 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - extended_location: Optional["ExtendedLocation"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, incremental: Optional[bool] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, - security_profile: Optional["DiskSecurityProfile"] = None, + security_profile: Optional["_models.DiskSecurityProfile"] = None, supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, completion_percent: Optional[float] = None, - data_access_auth_mode: Optional[Union[str, "DataAccessAuthMode"]] = None, + data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, **kwargs ): """ @@ -2588,10 +2587,10 @@ def __init__( :keyword extended_location: The extended location where the snapshot will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2021_12_01.models.ExtendedLocation - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_12_01.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2021_12_01.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. @@ -2617,8 +2616,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2021_12_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_12_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -2628,15 +2627,15 @@ def __init__( :paramtype security_profile: ~azure.mgmt.compute.v2021_12_01.models.DiskSecurityProfile :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_12_01.models.PublicNetworkAccess :keyword completion_percent: Percentage complete for the background copy when a resource is created via the CopyStart operation. :paramtype completion_percent: float :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + uploading to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.v2021_12_01.models.DataAccessAuthMode """ @@ -2691,7 +2690,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -2712,8 +2711,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2021_12_01.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -2731,12 +2729,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2021_12_01.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -2753,7 +2750,7 @@ class SnapshotUpdate(msrest.serialization.Model): an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. :vartype sku: ~azure.mgmt.compute.v2021_12_01.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2021_12_01.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -2767,20 +2764,20 @@ class SnapshotUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2021_12_01.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2021_12_01.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. :vartype disk_access_id: str :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2021_12_01.models.PublicNetworkAccess :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :vartype data_access_auth_mode: str or ~azure.mgmt.compute.v2021_12_01.models.DataAccessAuthMode :ivar supported_capabilities: List of supported capabilities for the image from which the OS @@ -2807,17 +2804,17 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "DataAccessAuthMode"]] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, **kwargs ): """ @@ -2827,7 +2824,7 @@ def __init__( is an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. :paramtype sku: ~azure.mgmt.compute.v2021_12_01.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2021_12_01.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -2841,8 +2838,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2021_12_01.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2021_12_01.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -2850,12 +2847,12 @@ def __init__( :paramtype disk_access_id: str :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2021_12_01.models.PublicNetworkAccess :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + uploading to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.v2021_12_01.models.DataAccessAuthMode :keyword supported_capabilities: List of supported capabilities for the image from which the OS @@ -2908,8 +2905,7 @@ class SupportedCapabilities(msrest.serialization.Model): :ivar accelerated_network: True if the image from which the OS disk is created supports accelerated networking. :vartype accelerated_network: bool - :ivar architecture: CPU architecture supported by an OS disk. Possible values include: "x64", - "Arm64". + :ivar architecture: CPU architecture supported by an OS disk. Known values are: "x64", "Arm64". :vartype architecture: str or ~azure.mgmt.compute.v2021_12_01.models.Architecture """ @@ -2922,15 +2918,15 @@ def __init__( self, *, accelerated_network: Optional[bool] = None, - architecture: Optional[Union[str, "Architecture"]] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, **kwargs ): """ :keyword accelerated_network: True if the image from which the OS disk is created supports accelerated networking. :paramtype accelerated_network: bool - :keyword architecture: CPU architecture supported by an OS disk. Possible values include: - "x64", "Arm64". + :keyword architecture: CPU architecture supported by an OS disk. Known values are: "x64", + "Arm64". :paramtype architecture: str or ~azure.mgmt.compute.v2021_12_01.models.Architecture """ super(SupportedCapabilities, self).__init__(**kwargs) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/__init__.py index c3e7f3bd4f2e..332fb79d2c68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/__init__.py @@ -12,6 +12,9 @@ from ._disk_accesses_operations import DiskAccessesOperations from ._disk_restore_point_operations import DiskRestorePointOperations +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__ = [ 'DisksOperations', 'SnapshotsOperations', @@ -19,3 +22,5 @@ 'DiskAccessesOperations', 'DiskRestorePointOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disk_accesses_operations.py index bfd94ef9975b..acc8a0200872 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccess] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccessUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_get_private_link_resources_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,18 +284,16 @@ def build_get_private_link_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -297,14 +304,17 @@ def build_update_a_private_endpoint_connection_request_initial( disk_access_name: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -317,20 +327,18 @@ def build_update_a_private_endpoint_connection_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -344,9 +352,12 @@ def build_get_a_private_endpoint_connection_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -359,18 +370,16 @@ def build_get_a_private_endpoint_connection_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -382,9 +391,12 @@ def build_delete_a_private_endpoint_connection_request_initial( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -397,18 +409,16 @@ def build_delete_a_private_endpoint_connection_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -419,9 +429,12 @@ def build_list_private_endpoint_connections_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections") # pylint: disable=line-too-long path_format_arguments = { @@ -433,58 +446,57 @@ def build_list_private_endpoint_connections_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskAccessesOperations(object): - """DiskAccessesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_12_01.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -496,11 +508,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,9 +544,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -555,37 +569,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_12_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -602,17 +626,20 @@ def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -624,11 +651,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -658,9 +687,9 @@ def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -683,37 +712,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_12_01.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -732,7 +771,7 @@ def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -746,13 +785,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_12_01.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -761,11 +803,13 @@ def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -792,13 +836,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -807,11 +854,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -855,20 +904,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -878,8 +932,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -897,7 +957,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -907,13 +967,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -922,9 +985,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -933,9 +998,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -972,7 +1039,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -980,13 +1047,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -994,9 +1064,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1004,9 +1076,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1045,7 +1119,7 @@ def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -1059,13 +1133,16 @@ def get_private_link_resources( :rtype: ~azure.mgmt.compute.v2021_12_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', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -1074,11 +1151,13 @@ def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1104,17 +1183,20 @@ def _update_a_private_endpoint_connection_initial( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.PrivateEndpointConnection] _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') @@ -1127,11 +1209,13 @@ def _update_a_private_endpoint_connection_initial( content_type=content_type, json=_json, template_url=self._update_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1162,9 +1246,9 @@ def begin_update_a_private_endpoint_connection( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection under disk access resource, this can't be used to create a new private endpoint connection. @@ -1194,17 +1278,20 @@ def begin_update_a_private_endpoint_connection( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_12_01.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.PrivateEndpointConnection] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_a_private_endpoint_connection_initial( + raw_result = self._update_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -1212,20 +1299,27 @@ def begin_update_a_private_endpoint_connection( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -1245,7 +1339,7 @@ def get_a_private_endpoint_connection( disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about a private endpoint connection under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1261,13 +1355,16 @@ def get_a_private_endpoint_connection( :rtype: ~azure.mgmt.compute.v2021_12_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', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_a_private_endpoint_connection_request( @@ -1277,11 +1374,13 @@ def get_a_private_endpoint_connection( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get_a_private_endpoint_connection.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1309,13 +1408,16 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsiste private_endpoint_connection_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', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_a_private_endpoint_connection_request_initial( @@ -1325,11 +1427,13 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsiste private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1376,21 +1480,26 @@ def begin_delete_a_private_endpoint_connection( # pylint: disable=inconsistent- :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_a_private_endpoint_connection_initial( + raw_result = self._delete_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1400,8 +1509,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1420,7 +1535,7 @@ def list_private_endpoint_connections( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List information about private endpoint connections under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1436,13 +1551,16 @@ def list_private_endpoint_connections( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_12_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - 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: @@ -1452,9 +1570,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=self.list_private_endpoint_connections.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1464,9 +1584,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disk_encryption_sets_operations.py index e5503539f0ee..c88a307228d3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_list_associated_resources_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,58 +284,57 @@ def build_list_associated_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskEncryptionSetsOperations(object): - """DiskEncryptionSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_12_01.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -338,11 +346,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -372,9 +382,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -399,37 +409,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -446,17 +466,20 @@ def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -468,11 +491,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,9 +527,9 @@ def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -529,37 +554,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -578,7 +613,7 @@ def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -592,13 +627,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -607,11 +645,13 @@ def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -638,13 +678,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -653,11 +696,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -701,20 +746,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -724,8 +774,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -743,7 +799,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -755,13 +811,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -770,9 +829,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -781,9 +842,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -820,7 +883,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -830,13 +893,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -844,9 +910,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -854,9 +922,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -895,7 +965,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> Iterable["_models.ResourceUriList"]: + ) -> Iterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -909,13 +979,16 @@ def list_associated_resources( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_12_01.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -925,9 +998,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -937,9 +1012,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disk_restore_point_operations.py index 2baa11e0ba0b..a5ce220852d1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disk_restore_point_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +37,12 @@ def build_get_request( disk_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,18 +56,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -76,9 +77,12 @@ def build_list_by_restore_point_request( vm_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints") # pylint: disable=line-too-long path_format_arguments = { @@ -91,18 +95,16 @@ def build_list_by_restore_point_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -114,14 +116,17 @@ def build_grant_access_request_initial( vm_restore_point_name: str, disk_restore_point_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -135,20 +140,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -163,9 +166,12 @@ def build_revoke_access_request_initial( disk_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -179,42 +185,38 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class DiskRestorePointOperations(object): - """DiskRestorePointOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskRestorePointOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_12_01.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -224,7 +226,7 @@ def get( vm_restore_point_name: str, disk_restore_point_name: str, **kwargs: Any - ) -> "_models.DiskRestorePoint": + ) -> _models.DiskRestorePoint: """Get disk restorePoint resource. :param resource_group_name: The name of the resource group. @@ -242,13 +244,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_12_01.models.DiskRestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePoint] request = build_get_request( @@ -259,11 +264,13 @@ def get( disk_restore_point_name=disk_restore_point_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -291,7 +298,7 @@ def list_by_restore_point( restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> Iterable["_models.DiskRestorePointList"]: + ) -> Iterable[_models.DiskRestorePointList]: """Lists diskRestorePoints under a vmRestorePoint. :param resource_group_name: The name of the resource group. @@ -309,13 +316,16 @@ def list_by_restore_point( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskRestorePointList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePointList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePointList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -326,9 +336,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=self.list_by_restore_point.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -339,9 +351,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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,17 +394,20 @@ def _grant_access_initial( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -404,11 +421,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,9 +457,9 @@ def begin_grant_access( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a diskRestorePoint. :param resource_group_name: The name of the resource group. @@ -468,17 +487,20 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_12_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, @@ -487,20 +509,27 @@ def begin_grant_access( 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('AccessUri', 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( @@ -521,13 +550,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_restore_point_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', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -538,11 +570,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_restore_point_name=disk_restore_point_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -592,22 +626,27 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, disk_restore_point_name=disk_restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -617,8 +656,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disks_operations.py index c984c68156c1..0cca84784b0a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_12_01.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_12_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_12_01.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_12_01.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_12_01.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_12_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_snapshots_operations.py index bcca8a613552..2f2f4b84a3ca 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2021_12_01/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2021_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.compute.v2021_12_01.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_12_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_12_01.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2021_12_01.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_12_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2021_12_01.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2021_12_01.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2021-12-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2021-12-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, 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-12-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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/__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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_compute_management_client.py index 90e59fa55ea9..1cb108569a23 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_compute_management_client.py @@ -86,18 +86,42 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_sharing_profile = GallerySharingProfileOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_galleries = SharedGalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_gallery_images = SharedGalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.community_galleries = CommunityGalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.community_gallery_images = CommunityGalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_sharing_profile = GallerySharingProfileOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_galleries = SharedGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_images = SharedGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_galleries = CommunityGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_gallery_images = CommunityGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/_compute_management_client.py index 4a5297cbbb07..b8eca4aace6d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/_compute_management_client.py @@ -87,18 +87,42 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.galleries = GalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_image_versions = GalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_applications = GalleryApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_application_versions = GalleryApplicationVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.gallery_sharing_profile = GallerySharingProfileOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_galleries = SharedGalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_gallery_images = SharedGalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.community_galleries = CommunityGalleriesOperations(self._client, self._config, self._serialize, self._deserialize) - self.community_gallery_images = CommunityGalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.galleries = GalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_images = GalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_image_versions = GalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_applications = GalleryApplicationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_application_versions = GalleryApplicationVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.gallery_sharing_profile = GallerySharingProfileOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_galleries = SharedGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_images = SharedGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.shared_gallery_image_versions = SharedGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_galleries = CommunityGalleriesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_gallery_images = CommunityGalleryImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.community_gallery_image_versions = CommunityGalleryImageVersionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/__init__.py index 336e2221f2b0..a78779994ddb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/__init__.py @@ -19,6 +19,9 @@ from ._community_gallery_images_operations import CommunityGalleryImagesOperations from ._community_gallery_image_versions_operations import CommunityGalleryImageVersionsOperations +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__ = [ 'GalleriesOperations', 'GalleryImagesOperations', @@ -33,3 +36,5 @@ 'CommunityGalleryImagesOperations', 'CommunityGalleryImageVersionsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_community_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_community_galleries_operations.py index 2080b498b67d..18c5d22396e8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_community_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_community_galleries_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CommunityGalleriesOperations: - """CommunityGalleriesOperations async operations. - - You 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.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s + :attr:`community_galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -49,7 +48,7 @@ async def get( location: str, public_gallery_name: str, **kwargs: Any - ) -> "_models.CommunityGallery": + ) -> _models.CommunityGallery: """Get a community gallery by gallery public name. :param location: Resource location. @@ -61,13 +60,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.CommunityGallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGallery] request = build_get_request( @@ -76,11 +78,13 @@ async def get( public_gallery_name=public_gallery_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_community_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_community_gallery_image_versions_operations.py index 27b5793c522a..546745ad5ff0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_community_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_community_gallery_image_versions_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CommunityGalleryImageVersionsOperations: - """CommunityGalleryImageVersionsOperations async operations. - - You 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.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s + :attr:`community_gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +52,7 @@ async def get( gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any - ) -> "_models.CommunityGalleryImageVersion": + ) -> _models.CommunityGalleryImageVersion: """Get a community gallery image version. :param location: Resource location. @@ -72,13 +71,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.CommunityGalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGalleryImageVersion] request = build_get_request( @@ -89,11 +91,13 @@ async def get( gallery_image_version_name=gallery_image_version_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,7 +125,7 @@ def list( public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CommunityGalleryImageVersionList"]: + ) -> AsyncIterable[_models.CommunityGalleryImageVersionList]: """List community gallery image versions inside an image. :param location: Resource location. @@ -137,13 +141,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_03.models.CommunityGalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -154,9 +161,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -167,9 +176,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_community_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_community_gallery_images_operations.py index 1331c7b631f7..e665aed72055 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_community_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_community_gallery_images_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CommunityGalleryImagesOperations: - """CommunityGalleryImagesOperations async operations. - - You 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.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s + :attr:`community_gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.CommunityGalleryImage": + ) -> _models.CommunityGalleryImage: """Get a community gallery image. :param location: Resource location. @@ -66,13 +65,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.CommunityGalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGalleryImage] request = build_get_request( @@ -82,11 +84,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,7 +117,7 @@ def list( location: str, public_gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CommunityGalleryImageList"]: + ) -> AsyncIterable[_models.CommunityGalleryImageList]: """List community gallery images inside a gallery. :param location: Resource location. @@ -127,13 +131,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_03.models.CommunityGalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -143,9 +150,11 @@ def prepare_request(next_link=None): public_gallery_name=public_gallery_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -155,9 +164,11 @@ def prepare_request(next_link=None): public_gallery_name=public_gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_galleries_operations.py index 2b37e25d5d31..a05cd06ba394 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleriesOperations: - """GalleriesOperations async operations. - - You 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.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'GalleryUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -234,9 +253,9 @@ async def begin_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Gallery"]: + ) -> AsyncLROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -259,37 +278,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -310,7 +339,7 @@ async def get( select: Optional[Union[str, "_models.SelectPermissions"]] = None, expand: Optional[Union[str, "_models.GalleryExpandParams"]] = None, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -326,13 +355,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -343,11 +375,13 @@ async def get( select=select, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -374,13 +408,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -389,11 +426,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -435,20 +474,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -458,8 +502,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -477,7 +527,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -488,13 +538,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_03.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +556,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -514,9 +569,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -553,7 +610,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.GalleryList"]: + ) -> AsyncIterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -562,13 +619,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_03.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -576,9 +636,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -586,9 +648,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_application_versions_operations.py index 5f9d38783d06..4bc6ed7e8d75 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationVersionsOperations: - """GalleryApplicationVersionsOperations async operations. - - You 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.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -152,17 +156,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -171,20 +178,27 @@ async def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -203,17 +217,20 @@ async def _update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersionUpdate') @@ -227,11 +244,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -259,9 +278,9 @@ async def begin_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplicationVersion"]: + ) -> AsyncLROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -295,17 +314,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -314,20 +336,27 @@ async def begin_update( 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('GalleryApplicationVersion', 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( @@ -349,7 +378,7 @@ async def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -370,13 +399,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -388,11 +420,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -421,13 +455,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -438,11 +475,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -493,22 +532,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -518,8 +562,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -539,7 +589,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationVersionList"]: + ) -> AsyncIterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -557,13 +607,16 @@ def list_by_gallery_application( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -574,9 +627,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -587,9 +642,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_applications_operations.py index 4dd2fee4a383..9edf6cf72ffe 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryApplicationsOperations: - """GalleryApplicationsOperations async operations. - - You 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.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -144,17 +148,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -162,20 +169,27 @@ async def begin_create_or_update( 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('GalleryApplication', 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( @@ -193,17 +207,20 @@ async def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplicationUpdate') @@ -216,11 +233,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryApplication"]: + ) -> AsyncLROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -277,17 +296,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -295,20 +317,27 @@ async def begin_update( 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('GalleryApplication', 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( @@ -328,7 +357,7 @@ async def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -344,13 +373,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -360,11 +392,13 @@ async def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,13 +426,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -408,11 +445,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,21 +497,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -482,8 +526,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -502,7 +552,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryApplicationList"]: + ) -> AsyncIterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -517,13 +567,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -533,9 +586,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -545,9 +600,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_image_versions_operations.py index 840a89dc4300..8ba007d23592 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImageVersionsOperations: - """GalleryImageVersionsOperations async operations. - - You 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.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,17 +52,20 @@ async def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -77,11 +79,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -116,9 +120,9 @@ async def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Create or update a gallery image version. :param resource_group_name: The name of the resource group. @@ -151,17 +155,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -170,20 +177,27 @@ async def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -202,17 +216,20 @@ async def _update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersionUpdate') @@ -226,11 +243,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -258,9 +277,9 @@ async def begin_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImageVersion"]: + ) -> AsyncLROPoller[_models.GalleryImageVersion]: """Update a gallery image version. :param resource_group_name: The name of the resource group. @@ -293,17 +312,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -312,20 +334,27 @@ async def begin_update( 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('GalleryImageVersion', 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( @@ -347,7 +376,7 @@ async def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery image version. :param resource_group_name: The name of the resource group. @@ -367,13 +396,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -385,11 +417,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -418,13 +452,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -435,11 +472,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -489,22 +528,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -514,8 +558,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -535,7 +585,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageVersionList"]: + ) -> AsyncIterable[_models.GalleryImageVersionList]: """List gallery image versions in a gallery image definition. :param resource_group_name: The name of the resource group. @@ -553,13 +603,16 @@ def list_by_gallery_image( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +623,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +638,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_images_operations.py index 47c9b91e176c..94a099666d3d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GalleryImagesOperations: - """GalleryImagesOperations async operations. - - You 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.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,9 +117,9 @@ async def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Create or update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -160,20 +167,27 @@ async def begin_create_or_update( 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('GalleryImage', 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( @@ -191,17 +205,20 @@ async def _update_initial( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImageUpdate') @@ -214,11 +231,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -245,9 +264,9 @@ async def begin_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.GalleryImage"]: + ) -> AsyncLROPoller[_models.GalleryImage]: """Update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -274,17 +293,20 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -292,20 +314,27 @@ async def begin_update( 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('GalleryImage', 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( @@ -325,7 +354,7 @@ async def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery image definition. :param resource_group_name: The name of the resource group. @@ -340,13 +369,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -356,11 +388,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -388,13 +422,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -404,11 +441,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -454,21 +493,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -478,8 +522,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -498,7 +548,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> AsyncIterable["_models.GalleryImageList"]: + ) -> AsyncIterable[_models.GalleryImageList]: """List gallery image definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -512,13 +562,16 @@ def list_by_gallery( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_03.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -528,9 +581,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -540,9 +595,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_sharing_profile_operations.py index 342592334e81..4217fdabe54e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_sharing_profile_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_gallery_sharing_profile_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,42 +25,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class GallerySharingProfileOperations: - """GallerySharingProfileOperations async operations. - - You 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.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s + :attr:`gallery_sharing_profile` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _update_initial( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> "_models.SharingUpdate": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] + ) -> _models.SharingUpdate: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharingUpdate] _json = self._serialize.body(sharing_update, 'SharingUpdate') @@ -71,11 +73,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,9 +109,9 @@ async def begin_update( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.SharingUpdate"]: + ) -> AsyncLROPoller[_models.SharingUpdate]: """Update sharing profile of a gallery. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_01_03.models.SharingUpdate] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharingUpdate] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, sharing_update=sharing_update, 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('SharingUpdate', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_shared_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_shared_galleries_operations.py index b95996231b14..76c3bf4024de 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_shared_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_shared_galleries_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SharedGalleriesOperations: - """SharedGalleriesOperations async operations. - - You 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.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s + :attr:`shared_galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -51,7 +50,7 @@ def list( location: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.SharedGalleryList"]: + ) -> AsyncIterable[_models.SharedGalleryList]: """List shared galleries by subscription id or tenant id. :param location: Resource location. @@ -65,13 +64,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_03.models.SharedGalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +83,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -93,9 +97,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +140,7 @@ async def get( location: str, gallery_unique_name: str, **kwargs: Any - ) -> "_models.SharedGallery": + ) -> _models.SharedGallery: """Get a shared gallery by subscription id or tenant id. :param location: Resource location. @@ -146,13 +152,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.SharedGallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGallery] request = build_get_request( @@ -161,11 +170,13 @@ async def get( gallery_unique_name=gallery_unique_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_shared_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_shared_gallery_image_versions_operations.py index 3bb412fae27b..a01fadd1602c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_shared_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_shared_gallery_image_versions_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SharedGalleryImageVersionsOperations: - """SharedGalleryImageVersionsOperations async operations. - - You 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.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s + :attr:`shared_gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -53,7 +52,7 @@ def list( gallery_image_name: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.SharedGalleryImageVersionList"]: + ) -> AsyncIterable[_models.SharedGalleryImageVersionList]: """List shared gallery image versions by subscription id or tenant id. :param location: Resource location. @@ -73,13 +72,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_03.models.SharedGalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +93,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_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,9 +109,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -148,7 +154,7 @@ async def get( gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any - ) -> "_models.SharedGalleryImageVersion": + ) -> _models.SharedGalleryImageVersion: """Get a shared gallery image version by subscription id or tenant id. :param location: Resource location. @@ -168,13 +174,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageVersion] request = build_get_request( @@ -185,11 +194,13 @@ async def get( gallery_image_version_name=gallery_image_version_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_shared_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_shared_gallery_images_operations.py index 4f41c1e97ec9..ef5aac0e2e0a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_shared_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/aio/operations/_shared_gallery_images_operations.py @@ -15,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 @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SharedGalleryImagesOperations: - """SharedGalleryImagesOperations async operations. - - You 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.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.aio.ComputeManagementClient`'s + :attr:`shared_gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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 +51,7 @@ def list( gallery_unique_name: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.SharedGalleryImageList"]: + ) -> AsyncIterable[_models.SharedGalleryImageList]: """List shared gallery images by subscription id or tenant id. :param location: Resource location. @@ -69,13 +68,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_01_03.models.SharedGalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -86,9 +88,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -99,9 +103,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -141,7 +147,7 @@ async def get( gallery_unique_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.SharedGalleryImage": + ) -> _models.SharedGalleryImage: """Get a shared gallery image by subscription id or tenant id. :param location: Resource location. @@ -156,13 +162,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImage] request = build_get_request( @@ -172,11 +181,13 @@ async def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/__init__.py index b6e23a2b5412..fb407204ca48 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/__init__.py @@ -112,7 +112,9 @@ SharingUpdateOperationTypes, StorageAccountType, ) - +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__ = [ 'ApiError', 'ApiErrorBase', @@ -217,3 +219,5 @@ 'SharingUpdateOperationTypes', 'StorageAccountType', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_compute_management_client_enums.py index d1a70d0bc785..f953a8c83465 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_compute_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AggregatedReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the aggregated replication status based on all the regional replication status flags. """ @@ -20,14 +19,14 @@ class AggregatedReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, En COMPLETED = "Completed" FAILED = "Failed" -class Architecture(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The architecture of the image. Applicable to OS disks only. """ X64 = "x64" ARM64 = "Arm64" -class ConfidentialVMEncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConfidentialVMEncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """confidential VM encryption types """ @@ -35,24 +34,24 @@ class ConfidentialVMEncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, ENCRYPTED_WITH_PMK = "EncryptedWithPmk" ENCRYPTED_WITH_CMK = "EncryptedWithCmk" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class GalleryExpandParams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryExpandParams(str, Enum, metaclass=CaseInsensitiveEnumMeta): SHARING_PROFILE_GROUPS = "SharingProfile/Groups" -class GalleryExtendedLocationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryExtendedLocationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """It is type of the extended location. """ EDGE_ZONE = "EdgeZone" UNKNOWN = "Unknown" -class GalleryProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GalleryProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provisioning state, which only appears in the response. """ @@ -63,7 +62,7 @@ class GalleryProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum DELETING = "Deleting" MIGRATING = "Migrating" -class GallerySharingPermissionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GallerySharingPermissionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the permission of sharing gallery. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Private** :code:`
`:code:`
` **Groups** :code:`
`:code:`
` **Community** @@ -73,7 +72,7 @@ class GallerySharingPermissionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, GROUPS = "Groups" COMMUNITY = "Community" -class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite' """ @@ -81,14 +80,14 @@ class HostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows the user to specify whether the virtual machines created under this image are 'Generalized' or 'Specialized'. """ @@ -96,7 +95,7 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu GENERALIZED = "Generalized" SPECIALIZED = "Specialized" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux** @@ -105,7 +104,7 @@ class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WINDOWS = "Windows" LINUX = "Linux" -class ReplicationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Optional parameter which specifies the mode to be used for replication. This property is not updatable. """ @@ -113,7 +112,7 @@ class ReplicationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FULL = "Full" SHALLOW = "Shallow" -class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is the regional replication state. """ @@ -122,15 +121,15 @@ class ReplicationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAILED = "Failed" -class ReplicationStatusTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReplicationStatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): REPLICATION_STATUS = "ReplicationStatus" -class SelectPermissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SelectPermissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): PERMISSIONS = "Permissions" -class SharedGalleryHostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharedGalleryHostCaching(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite' """ @@ -138,11 +137,11 @@ class SharedGalleryHostCaching(with_metaclass(CaseInsensitiveEnumMeta, str, Enum READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class SharedToValues(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharedToValues(str, Enum, metaclass=CaseInsensitiveEnumMeta): TENANT = "tenant" -class SharingProfileGroupTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharingProfileGroupTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the type of sharing group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Subscriptions** :code:`
`:code:`
` **AADTenants** @@ -151,7 +150,7 @@ class SharingProfileGroupTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum SUBSCRIPTIONS = "Subscriptions" AAD_TENANTS = "AADTenants" -class SharingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sharing state of the gallery, which only appears in the response. """ @@ -160,7 +159,7 @@ class SharingState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" UNKNOWN = "Unknown" -class SharingUpdateOperationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SharingUpdateOperationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the operation type of gallery sharing update. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset** @@ -171,7 +170,7 @@ class SharingUpdateOperationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E RESET = "Reset" ENABLE_COMMUNITY = "EnableCommunity" -class StorageAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type to be used to store the image. This property is not updatable. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_models_py3.py index 08462477c170..c2daa3963a74 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class ApiError(msrest.serialization.Model): @@ -40,8 +42,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -207,11 +209,11 @@ class CommunityGalleryImage(PirCommunityGalleryResource): :vartype unique_id: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemStateTypes :ivar end_of_life_date: The end of life date of the gallery image definition. This property can @@ -225,15 +227,15 @@ class CommunityGalleryImage(PirCommunityGalleryResource): :ivar disallowed: Describes the disallowed disk types. :vartype disallowed: ~azure.mgmt.compute.v2022_01_03.models.Disallowed :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_01_03.models.HyperVGeneration :ivar features: A list of gallery image features. :vartype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan - :ivar architecture: The architecture of the image. Applicable to OS disks only. Possible values - include: "x64", "Arm64". + :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64", "Arm64". :vartype architecture: str or ~azure.mgmt.compute.v2022_01_03.models.Architecture :ivar privacy_statement_uri: Privacy statement uri for the current community gallery image. :vartype privacy_statement_uri: str @@ -270,16 +272,16 @@ def __init__( self, *, unique_id: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - features: Optional[List["GalleryImageFeature"]] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, - architecture: Optional[Union[str, "Architecture"]] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, privacy_statement_uri: Optional[str] = None, eula: Optional[str] = None, **kwargs @@ -289,12 +291,12 @@ def __init__( :paramtype unique_id: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemStateTypes :keyword end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -307,15 +309,15 @@ def __init__( :keyword disallowed: Describes the disallowed disk types. :paramtype disallowed: ~azure.mgmt.compute.v2022_01_03.models.Disallowed :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2022_01_03.models.HyperVGeneration :keyword features: A list of gallery image features. :paramtype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by marketplace images. :paramtype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan - :keyword architecture: The architecture of the image. Applicable to OS disks only. Possible - values include: "x64", "Arm64". + :keyword architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64", "Arm64". :paramtype architecture: str or ~azure.mgmt.compute.v2022_01_03.models.Architecture :keyword privacy_statement_uri: Privacy statement uri for the current community gallery image. :paramtype privacy_statement_uri: str @@ -361,7 +363,7 @@ class CommunityGalleryImageList(msrest.serialization.Model): def __init__( self, *, - value: List["CommunityGalleryImage"], + value: List["_models.CommunityGalleryImage"], next_link: Optional[str] = None, **kwargs ): @@ -428,7 +430,7 @@ def __init__( published_date: Optional[datetime.datetime] = None, end_of_life_date: Optional[datetime.datetime] = None, exclude_from_latest: Optional[bool] = None, - storage_profile: Optional["SharedGalleryImageVersionStorageProfile"] = None, + storage_profile: Optional["_models.SharedGalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -478,7 +480,7 @@ class CommunityGalleryImageVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["CommunityGalleryImageVersion"], + value: List["_models.CommunityGalleryImageVersion"], next_link: Optional[str] = None, **kwargs ): @@ -672,8 +674,8 @@ class EncryptionImages(msrest.serialization.Model): def __init__( self, *, - os_disk_image: Optional["OSDiskImageEncryption"] = None, - data_disk_images: Optional[List["DataDiskImageEncryption"]] = None, + os_disk_image: Optional["_models.OSDiskImageEncryption"] = None, + data_disk_images: Optional[List["_models.DataDiskImageEncryption"]] = None, **kwargs ): """ @@ -693,7 +695,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.compute.v2022_01_03.models.ExtendedLocationTypes """ @@ -706,13 +708,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.compute.v2022_01_03.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -797,8 +799,8 @@ class Gallery(Resource): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2022_01_03.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. @@ -838,9 +840,9 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, - sharing_profile: Optional["SharingProfile"] = None, - soft_delete_policy: Optional["SoftDeletePolicy"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, + sharing_profile: Optional["_models.SharingProfile"] = None, + soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, **kwargs ): """ @@ -899,8 +901,8 @@ class GalleryApplication(Resource): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes """ @@ -935,7 +937,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -957,8 +959,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes """ @@ -995,7 +997,7 @@ class GalleryApplicationList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplication"], + value: List["_models.GalleryApplication"], next_link: Optional[str] = None, **kwargs ): @@ -1084,8 +1086,8 @@ class GalleryApplicationUpdate(UpdateResourceDefinition): :vartype end_of_life_date: ~datetime.datetime :ivar supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype supported_os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes """ @@ -1117,7 +1119,7 @@ def __init__( privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, end_of_life_date: Optional[datetime.datetime] = None, - supported_os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + supported_os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, **kwargs ): """ @@ -1137,8 +1139,8 @@ def __init__( :paramtype end_of_life_date: ~datetime.datetime :keyword supported_os_type: This property allows you to specify the supported type of the OS that application is built for. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype supported_os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes """ @@ -1171,8 +1173,8 @@ class GalleryApplicationVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState :ivar replication_status: This is the replication status of the gallery image version. @@ -1204,7 +1206,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -1246,7 +1248,7 @@ class GalleryApplicationVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryApplicationVersion"], + value: List["_models.GalleryApplicationVersion"], next_link: Optional[str] = None, **kwargs ): @@ -1283,11 +1285,11 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Possible values include: "Full", "Shallow". + This property is not updatable. Known values are: "Full", "Shallow". :vartype replication_mode: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationMode :ivar target_extended_locations: The target extended locations where the Image Version is going to be replicated to. This property is updatable. @@ -1313,13 +1315,13 @@ class GalleryArtifactPublishingProfileBase(msrest.serialization.Model): def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "ReplicationMode"]] = None, - target_extended_locations: Optional[List["GalleryTargetExtendedLocation"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, **kwargs ): """ @@ -1337,12 +1339,12 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Possible values include: "Full", "Shallow". + replication. This property is not updatable. Known values are: "Full", "Shallow". :paramtype replication_mode: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationMode :keyword target_extended_locations: The target extended locations where the Image Version is going to be replicated to. This property is updatable. @@ -1383,11 +1385,11 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Possible values include: "Full", "Shallow". + This property is not updatable. Known values are: "Full", "Shallow". :vartype replication_mode: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationMode :ivar target_extended_locations: The target extended locations where the Image Version is going to be replicated to. This property is updatable. @@ -1431,16 +1433,16 @@ class GalleryApplicationVersionPublishingProfile(GalleryArtifactPublishingProfil def __init__( self, *, - source: "UserArtifactSource", - target_regions: Optional[List["TargetRegion"]] = None, + source: "_models.UserArtifactSource", + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "ReplicationMode"]] = None, - target_extended_locations: Optional[List["GalleryTargetExtendedLocation"]] = None, - manage_actions: Optional["UserArtifactManage"] = None, - settings: Optional["UserArtifactSettings"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, + manage_actions: Optional["_models.UserArtifactManage"] = None, + settings: Optional["_models.UserArtifactSettings"] = None, advanced_settings: Optional[Dict[str, str]] = None, enable_health_check: Optional[bool] = None, **kwargs @@ -1460,12 +1462,12 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Possible values include: "Full", "Shallow". + replication. This property is not updatable. Known values are: "Full", "Shallow". :paramtype replication_mode: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationMode :keyword target_extended_locations: The target extended locations where the Image Version is going to be replicated to. This property is updatable. @@ -1509,8 +1511,8 @@ class GalleryApplicationVersionUpdate(UpdateResourceDefinition): :ivar publishing_profile: The publishing profile of a gallery image version. :vartype publishing_profile: ~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState :ivar replication_status: This is the replication status of the gallery image version. @@ -1539,7 +1541,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryApplicationVersionPublishingProfile"] = None, + publishing_profile: Optional["_models.GalleryApplicationVersionPublishingProfile"] = None, **kwargs ): """ @@ -1575,7 +1577,7 @@ class GalleryArtifactSource(msrest.serialization.Model): def __init__( self, *, - managed_image: "ManagedArtifact", + managed_image: "_models.ManagedArtifact", **kwargs ): """ @@ -1630,7 +1632,7 @@ class GalleryDiskImage(msrest.serialization.Model): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource @@ -1649,13 +1651,13 @@ class GalleryDiskImage(msrest.serialization.Model): def __init__( self, *, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource @@ -1676,7 +1678,7 @@ class GalleryDataDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource @@ -1702,13 +1704,13 @@ def __init__( self, *, lun: int, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource @@ -1726,8 +1728,7 @@ class GalleryExtendedLocation(msrest.serialization.Model): :ivar name: :vartype name: str - :ivar type: It is type of the extended location. Possible values include: "EdgeZone", - "Unknown". + :ivar type: It is type of the extended location. Known values are: "EdgeZone", "Unknown". :vartype type: str or ~azure.mgmt.compute.v2022_01_03.models.GalleryExtendedLocationType """ @@ -1740,14 +1741,13 @@ def __init__( self, *, name: Optional[str] = None, - type: Optional[Union[str, "GalleryExtendedLocationType"]] = None, + type: Optional[Union[str, "_models.GalleryExtendedLocationType"]] = None, **kwargs ): """ :keyword name: :paramtype name: str - :keyword type: It is type of the extended location. Possible values include: "EdgeZone", - "Unknown". + :keyword type: It is type of the extended location. Known values are: "EdgeZone", "Unknown". :paramtype type: str or ~azure.mgmt.compute.v2022_01_03.models.GalleryExtendedLocationType """ super(GalleryExtendedLocation, self).__init__(**kwargs) @@ -1811,15 +1811,15 @@ class GalleryImage(Resource): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemStateTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_01_03.models.HyperVGeneration :ivar end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -1834,14 +1834,14 @@ class GalleryImage(Resource): :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState :ivar features: A list of gallery image features. :vartype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] - :ivar architecture: The architecture of the image. Applicable to OS disks only. Possible values - include: "x64", "Arm64". + :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64", "Arm64". :vartype architecture: str or ~azure.mgmt.compute.v2022_01_03.models.Architecture """ @@ -1885,16 +1885,16 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, - features: Optional[List["GalleryImageFeature"]] = None, - architecture: Optional[Union[str, "Architecture"]] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, **kwargs ): """ @@ -1913,15 +1913,15 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemStateTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2022_01_03.models.HyperVGeneration :keyword end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -1938,8 +1938,8 @@ def __init__( :paramtype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan :keyword features: A list of gallery image features. :paramtype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] - :keyword architecture: The architecture of the image. Applicable to OS disks only. Possible - values include: "x64", "Arm64". + :keyword architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64", "Arm64". :paramtype architecture: str or ~azure.mgmt.compute.v2022_01_03.models.Architecture """ super(GalleryImage, self).__init__(location=location, tags=tags, **kwargs) @@ -2063,7 +2063,7 @@ class GalleryImageList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImage"], + value: List["_models.GalleryImage"], next_link: Optional[str] = None, **kwargs ): @@ -2103,15 +2103,15 @@ class GalleryImageUpdate(UpdateResourceDefinition): :vartype release_note_uri: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemStateTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_01_03.models.HyperVGeneration :ivar end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -2126,14 +2126,14 @@ class GalleryImageUpdate(UpdateResourceDefinition): :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState :ivar features: A list of gallery image features. :vartype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] - :ivar architecture: The architecture of the image. Applicable to OS disks only. Possible values - include: "x64", "Arm64". + :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64", "Arm64". :vartype architecture: str or ~azure.mgmt.compute.v2022_01_03.models.Architecture """ @@ -2174,16 +2174,16 @@ def __init__( eula: Optional[str] = None, privacy_statement_uri: Optional[str] = None, release_note_uri: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, - features: Optional[List["GalleryImageFeature"]] = None, - architecture: Optional[Union[str, "Architecture"]] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, **kwargs ): """ @@ -2200,15 +2200,15 @@ def __init__( :paramtype release_note_uri: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemStateTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2022_01_03.models.HyperVGeneration :keyword end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -2225,8 +2225,8 @@ def __init__( :paramtype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan :keyword features: A list of gallery image features. :paramtype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] - :keyword architecture: The architecture of the image. Applicable to OS disks only. Possible - values include: "x64", "Arm64". + :keyword architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64", "Arm64". :paramtype architecture: str or ~azure.mgmt.compute.v2022_01_03.models.Architecture """ super(GalleryImageUpdate, self).__init__(tags=tags, **kwargs) @@ -2267,8 +2267,8 @@ class GalleryImageVersion(Resource): :ivar publishing_profile: The publishing profile of a gallery image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -2304,8 +2304,8 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["GalleryImageVersionStorageProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -2351,7 +2351,7 @@ class GalleryImageVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["GalleryImageVersion"], + value: List["_models.GalleryImageVersion"], next_link: Optional[str] = None, **kwargs ): @@ -2388,11 +2388,11 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) used for decommissioning purposes. This property is updatable. :vartype end_of_life_date: ~datetime.datetime :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType :ivar replication_mode: Optional parameter which specifies the mode to be used for replication. - This property is not updatable. Possible values include: "Full", "Shallow". + This property is not updatable. Known values are: "Full", "Shallow". :vartype replication_mode: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationMode :ivar target_extended_locations: The target extended locations where the Image Version is going to be replicated to. This property is updatable. @@ -2418,13 +2418,13 @@ class GalleryImageVersionPublishingProfile(GalleryArtifactPublishingProfileBase) def __init__( self, *, - target_regions: Optional[List["TargetRegion"]] = None, + target_regions: Optional[List["_models.TargetRegion"]] = None, replica_count: Optional[int] = None, exclude_from_latest: Optional[bool] = None, end_of_life_date: Optional[datetime.datetime] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - replication_mode: Optional[Union[str, "ReplicationMode"]] = None, - target_extended_locations: Optional[List["GalleryTargetExtendedLocation"]] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + replication_mode: Optional[Union[str, "_models.ReplicationMode"]] = None, + target_extended_locations: Optional[List["_models.GalleryTargetExtendedLocation"]] = None, **kwargs ): """ @@ -2442,12 +2442,12 @@ def __init__( be used for decommissioning purposes. This property is updatable. :paramtype end_of_life_date: ~datetime.datetime :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType :keyword replication_mode: Optional parameter which specifies the mode to be used for - replication. This property is not updatable. Possible values include: "Full", "Shallow". + replication. This property is not updatable. Known values are: "Full", "Shallow". :paramtype replication_mode: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationMode :keyword target_extended_locations: The target extended locations where the Image Version is going to be replicated to. This property is updatable. @@ -2477,9 +2477,9 @@ class GalleryImageVersionStorageProfile(msrest.serialization.Model): def __init__( self, *, - source: Optional["GalleryArtifactVersionSource"] = None, - os_disk_image: Optional["GalleryOSDiskImage"] = None, - data_disk_images: Optional[List["GalleryDataDiskImage"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, + os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, + data_disk_images: Optional[List["_models.GalleryDataDiskImage"]] = None, **kwargs ): """ @@ -2512,8 +2512,8 @@ class GalleryImageVersionUpdate(UpdateResourceDefinition): :ivar publishing_profile: The publishing profile of a gallery image Version. :vartype publishing_profile: ~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersionPublishingProfile - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState :ivar storage_profile: This is the storage profile of a Gallery Image Version. @@ -2546,8 +2546,8 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - publishing_profile: Optional["GalleryImageVersionPublishingProfile"] = None, - storage_profile: Optional["GalleryImageVersionStorageProfile"] = None, + publishing_profile: Optional["_models.GalleryImageVersionPublishingProfile"] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -2591,7 +2591,7 @@ class GalleryList(msrest.serialization.Model): def __init__( self, *, - value: List["Gallery"], + value: List["_models.Gallery"], next_link: Optional[str] = None, **kwargs ): @@ -2615,7 +2615,7 @@ class GalleryOSDiskImage(GalleryDiskImage): :ivar size_in_gb: This property indicates the size of the VHD to be created. :vartype size_in_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.HostCaching :ivar source: The gallery artifact version source. :vartype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource @@ -2634,13 +2634,13 @@ class GalleryOSDiskImage(GalleryDiskImage): def __init__( self, *, - host_caching: Optional[Union[str, "HostCaching"]] = None, - source: Optional["GalleryArtifactVersionSource"] = None, + host_caching: Optional[Union[str, "_models.HostCaching"]] = None, + source: Optional["_models.GalleryArtifactVersionSource"] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.HostCaching :keyword source: The gallery artifact version source. :paramtype source: ~azure.mgmt.compute.v2022_01_03.models.GalleryArtifactVersionSource @@ -2659,7 +2659,7 @@ class GalleryTargetExtendedLocation(msrest.serialization.Model): created per extended location. This property is updatable. :vartype extended_location_replica_count: int :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS @@ -2679,10 +2679,10 @@ def __init__( self, *, name: Optional[str] = None, - extended_location: Optional["GalleryExtendedLocation"] = None, + extended_location: Optional["_models.GalleryExtendedLocation"] = None, extended_location_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - encryption: Optional["EncryptionImages"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + encryption: Optional["_models.EncryptionImages"] = None, **kwargs ): """ @@ -2694,7 +2694,7 @@ def __init__( created per extended location. This property is updatable. :paramtype extended_location_replica_count: int :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType @@ -2728,8 +2728,8 @@ class GalleryUpdate(UpdateResourceDefinition): :vartype description: str :ivar identifier: Describes the gallery unique name. :vartype identifier: ~azure.mgmt.compute.v2022_01_03.models.GalleryIdentifier - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or ~azure.mgmt.compute.v2022_01_03.models.GalleryProvisioningState :ivar sharing_profile: Profile for gallery sharing to subscription or tenant. @@ -2766,9 +2766,9 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, description: Optional[str] = None, - identifier: Optional["GalleryIdentifier"] = None, - sharing_profile: Optional["SharingProfile"] = None, - soft_delete_policy: Optional["SoftDeletePolicy"] = None, + identifier: Optional["_models.GalleryIdentifier"] = None, + sharing_profile: Optional["_models.SharingProfile"] = None, + soft_delete_policy: Optional["_models.SoftDeletePolicy"] = None, **kwargs ): """ @@ -2915,7 +2915,7 @@ def __init__( self, *, disk_encryption_set_id: Optional[str] = None, - security_profile: Optional["OSDiskImageSecurityProfile"] = None, + security_profile: Optional["_models.OSDiskImageSecurityProfile"] = None, **kwargs ): """ @@ -2932,8 +2932,8 @@ def __init__( class OSDiskImageSecurityProfile(msrest.serialization.Model): """Contains security profile for an OS disk image. - :ivar confidential_vm_encryption_type: confidential VM encryption types. Possible values - include: "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", "EncryptedWithCmk". + :ivar confidential_vm_encryption_type: confidential VM encryption types. Known values are: + "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", "EncryptedWithCmk". :vartype confidential_vm_encryption_type: str or ~azure.mgmt.compute.v2022_01_03.models.ConfidentialVMEncryptionType :ivar secure_vm_disk_encryption_set_id: secure VM disk encryption set id. @@ -2948,13 +2948,13 @@ class OSDiskImageSecurityProfile(msrest.serialization.Model): def __init__( self, *, - confidential_vm_encryption_type: Optional[Union[str, "ConfidentialVMEncryptionType"]] = None, + confidential_vm_encryption_type: Optional[Union[str, "_models.ConfidentialVMEncryptionType"]] = None, secure_vm_disk_encryption_set_id: Optional[str] = None, **kwargs ): """ - :keyword confidential_vm_encryption_type: confidential VM encryption types. Possible values - include: "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", "EncryptedWithCmk". + :keyword confidential_vm_encryption_type: confidential VM encryption types. Known values are: + "EncryptedVMGuestStateOnlyWithPmk", "EncryptedWithPmk", "EncryptedWithCmk". :paramtype confidential_vm_encryption_type: str or ~azure.mgmt.compute.v2022_01_03.models.ConfidentialVMEncryptionType :keyword secure_vm_disk_encryption_set_id: secure VM disk encryption set id. @@ -3052,8 +3052,8 @@ class RecommendedMachineConfiguration(msrest.serialization.Model): def __init__( self, *, - v_cp_us: Optional["ResourceRange"] = None, - memory: Optional["ResourceRange"] = None, + v_cp_us: Optional["_models.ResourceRange"] = None, + memory: Optional["_models.ResourceRange"] = None, **kwargs ): """ @@ -3074,7 +3074,7 @@ class RegionalReplicationStatus(msrest.serialization.Model): :ivar region: The region to which the gallery image version is being replicated to. :vartype region: str - :ivar state: This is the regional replication state. Possible values include: "Unknown", + :ivar state: This is the regional replication state. Known values are: "Unknown", "Replicating", "Completed", "Failed". :vartype state: str or ~azure.mgmt.compute.v2022_01_03.models.ReplicationState :ivar details: The details of the replication status. @@ -3117,7 +3117,7 @@ class RegionalSharingStatus(msrest.serialization.Model): :ivar region: Region name. :vartype region: str - :ivar state: Gallery sharing state in current region. Possible values include: "Succeeded", + :ivar state: Gallery sharing state in current region. Known values are: "Succeeded", "InProgress", "Failed", "Unknown". :vartype state: str or ~azure.mgmt.compute.v2022_01_03.models.SharingState :ivar details: Details of gallery regional sharing failure. @@ -3159,8 +3159,7 @@ class ReplicationStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar aggregated_state: This is the aggregated replication status based on all the regional - replication status flags. Possible values include: "Unknown", "InProgress", "Completed", - "Failed". + replication status flags. Known values are: "Unknown", "InProgress", "Completed", "Failed". :vartype aggregated_state: str or ~azure.mgmt.compute.v2022_01_03.models.AggregatedReplicationState :ivar summary: This is a summary of replication status for each region. @@ -3317,7 +3316,7 @@ class SharedGalleryDiskImage(msrest.serialization.Model): :ivar disk_size_gb: This property indicates the size of the VHD to be created. :vartype disk_size_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryHostCaching """ @@ -3333,12 +3332,12 @@ class SharedGalleryDiskImage(msrest.serialization.Model): def __init__( self, *, - host_caching: Optional[Union[str, "SharedGalleryHostCaching"]] = None, + host_caching: Optional[Union[str, "_models.SharedGalleryHostCaching"]] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryHostCaching """ super(SharedGalleryDiskImage, self).__init__(**kwargs) @@ -3356,7 +3355,7 @@ class SharedGalleryDataDiskImage(SharedGalleryDiskImage): :ivar disk_size_gb: This property indicates the size of the VHD to be created. :vartype disk_size_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryHostCaching :ivar lun: Required. This property specifies the logical unit number of the data disk. This value is used to identify data disks within the Virtual Machine and therefore must be unique @@ -3379,12 +3378,12 @@ def __init__( self, *, lun: int, - host_caching: Optional[Union[str, "SharedGalleryHostCaching"]] = None, + host_caching: Optional[Union[str, "_models.SharedGalleryHostCaching"]] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryHostCaching :keyword lun: Required. This property specifies the logical unit number of the data disk. This value is used to identify data disks within the Virtual Machine and therefore must be unique @@ -3408,11 +3407,11 @@ class SharedGalleryImage(PirSharedGalleryResource): :vartype unique_id: str :ivar os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes :ivar os_state: This property allows the user to specify whether the virtual machines created - under this image are 'Generalized' or 'Specialized'. Possible values include: "Generalized", + under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemStateTypes :ivar end_of_life_date: The end of life date of the gallery image definition. This property can @@ -3426,15 +3425,15 @@ class SharedGalleryImage(PirSharedGalleryResource): :ivar disallowed: Describes the disallowed disk types. :vartype disallowed: ~azure.mgmt.compute.v2022_01_03.models.Disallowed :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_01_03.models.HyperVGeneration :ivar features: A list of gallery image features. :vartype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] :ivar purchase_plan: Describes the gallery image definition purchase plan. This is used by marketplace images. :vartype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan - :ivar architecture: The architecture of the image. Applicable to OS disks only. Possible values - include: "x64", "Arm64". + :ivar architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64", "Arm64". :vartype architecture: str or ~azure.mgmt.compute.v2022_01_03.models.Architecture """ @@ -3463,16 +3462,16 @@ def __init__( self, *, unique_id: Optional[str] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - os_state: Optional[Union[str, "OperatingSystemStateTypes"]] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + os_state: Optional[Union[str, "_models.OperatingSystemStateTypes"]] = None, end_of_life_date: Optional[datetime.datetime] = None, - identifier: Optional["GalleryImageIdentifier"] = None, - recommended: Optional["RecommendedMachineConfiguration"] = None, - disallowed: Optional["Disallowed"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - features: Optional[List["GalleryImageFeature"]] = None, - purchase_plan: Optional["ImagePurchasePlan"] = None, - architecture: Optional[Union[str, "Architecture"]] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + recommended: Optional["_models.RecommendedMachineConfiguration"] = None, + disallowed: Optional["_models.Disallowed"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + features: Optional[List["_models.GalleryImageFeature"]] = None, + purchase_plan: Optional["_models.ImagePurchasePlan"] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, **kwargs ): """ @@ -3480,12 +3479,12 @@ def __init__( :paramtype unique_id: str :keyword os_type: This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image. :code:`
`:code:`
` Possible values are: - :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible values - include: "Windows", "Linux". + :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known values are: + "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemTypes :keyword os_state: This property allows the user to specify whether the virtual machines - created under this image are 'Generalized' or 'Specialized'. Possible values include: - "Generalized", "Specialized". + created under this image are 'Generalized' or 'Specialized'. Known values are: "Generalized", + "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2022_01_03.models.OperatingSystemStateTypes :keyword end_of_life_date: The end of life date of the gallery image definition. This property can be used for decommissioning purposes. This property is updatable. @@ -3498,15 +3497,15 @@ def __init__( :keyword disallowed: Describes the disallowed disk types. :paramtype disallowed: ~azure.mgmt.compute.v2022_01_03.models.Disallowed :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2022_01_03.models.HyperVGeneration :keyword features: A list of gallery image features. :paramtype features: list[~azure.mgmt.compute.v2022_01_03.models.GalleryImageFeature] :keyword purchase_plan: Describes the gallery image definition purchase plan. This is used by marketplace images. :paramtype purchase_plan: ~azure.mgmt.compute.v2022_01_03.models.ImagePurchasePlan - :keyword architecture: The architecture of the image. Applicable to OS disks only. Possible - values include: "x64", "Arm64". + :keyword architecture: The architecture of the image. Applicable to OS disks only. Known values + are: "x64", "Arm64". :paramtype architecture: str or ~azure.mgmt.compute.v2022_01_03.models.Architecture """ super(SharedGalleryImage, self).__init__(unique_id=unique_id, **kwargs) @@ -3546,7 +3545,7 @@ class SharedGalleryImageList(msrest.serialization.Model): def __init__( self, *, - value: List["SharedGalleryImage"], + value: List["_models.SharedGalleryImage"], next_link: Optional[str] = None, **kwargs ): @@ -3609,7 +3608,7 @@ def __init__( published_date: Optional[datetime.datetime] = None, end_of_life_date: Optional[datetime.datetime] = None, exclude_from_latest: Optional[bool] = None, - storage_profile: Optional["SharedGalleryImageVersionStorageProfile"] = None, + storage_profile: Optional["_models.SharedGalleryImageVersionStorageProfile"] = None, **kwargs ): """ @@ -3659,7 +3658,7 @@ class SharedGalleryImageVersionList(msrest.serialization.Model): def __init__( self, *, - value: List["SharedGalleryImageVersion"], + value: List["_models.SharedGalleryImageVersion"], next_link: Optional[str] = None, **kwargs ): @@ -3693,8 +3692,8 @@ class SharedGalleryImageVersionStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk_image: Optional["SharedGalleryOSDiskImage"] = None, - data_disk_images: Optional[List["SharedGalleryDataDiskImage"]] = None, + os_disk_image: Optional["_models.SharedGalleryOSDiskImage"] = None, + data_disk_images: Optional[List["_models.SharedGalleryDataDiskImage"]] = None, **kwargs ): """ @@ -3733,7 +3732,7 @@ class SharedGalleryList(msrest.serialization.Model): def __init__( self, *, - value: List["SharedGallery"], + value: List["_models.SharedGallery"], next_link: Optional[str] = None, **kwargs ): @@ -3757,7 +3756,7 @@ class SharedGalleryOSDiskImage(SharedGalleryDiskImage): :ivar disk_size_gb: This property indicates the size of the VHD to be created. :vartype disk_size_gb: int :ivar host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :vartype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryHostCaching """ @@ -3773,12 +3772,12 @@ class SharedGalleryOSDiskImage(SharedGalleryDiskImage): def __init__( self, *, - host_caching: Optional[Union[str, "SharedGalleryHostCaching"]] = None, + host_caching: Optional[Union[str, "_models.SharedGalleryHostCaching"]] = None, **kwargs ): """ :keyword host_caching: The host caching of the disk. Valid values are 'None', 'ReadOnly', and - 'ReadWrite'. Possible values include: "None", "ReadOnly", "ReadWrite". + 'ReadWrite'. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype host_caching: str or ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryHostCaching """ super(SharedGalleryOSDiskImage, self).__init__(host_caching=host_caching, **kwargs) @@ -3791,8 +3790,8 @@ class SharingProfile(msrest.serialization.Model): :ivar permissions: This property allows you to specify the permission of sharing gallery. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Private** - :code:`
`:code:`
` **Groups** :code:`
`:code:`
` **Community**. Possible values - include: "Private", "Groups", "Community". + :code:`
`:code:`
` **Groups** :code:`
`:code:`
` **Community**. Known values are: + "Private", "Groups", "Community". :vartype permissions: str or ~azure.mgmt.compute.v2022_01_03.models.GallerySharingPermissionTypes :ivar groups: A list of sharing profile groups. @@ -3815,15 +3814,15 @@ class SharingProfile(msrest.serialization.Model): def __init__( self, *, - permissions: Optional[Union[str, "GallerySharingPermissionTypes"]] = None, + permissions: Optional[Union[str, "_models.GallerySharingPermissionTypes"]] = None, community_gallery_info: Optional[Any] = None, **kwargs ): """ :keyword permissions: This property allows you to specify the permission of sharing gallery. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Private** - :code:`
`:code:`
` **Groups** :code:`
`:code:`
` **Community**. Possible values - include: "Private", "Groups", "Community". + :code:`
`:code:`
` **Groups** :code:`
`:code:`
` **Community**. Known values are: + "Private", "Groups", "Community". :paramtype permissions: str or ~azure.mgmt.compute.v2022_01_03.models.GallerySharingPermissionTypes :keyword community_gallery_info: Information of community gallery if current gallery is shared @@ -3841,8 +3840,7 @@ class SharingProfileGroup(msrest.serialization.Model): :ivar type: This property allows you to specify the type of sharing group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Subscriptions** - :code:`
`:code:`
` **AADTenants**. Possible values include: "Subscriptions", - "AADTenants". + :code:`
`:code:`
` **AADTenants**. Known values are: "Subscriptions", "AADTenants". :vartype type: str or ~azure.mgmt.compute.v2022_01_03.models.SharingProfileGroupTypes :ivar ids: A list of subscription/tenant ids the gallery is aimed to be shared to. :vartype ids: list[str] @@ -3856,15 +3854,14 @@ class SharingProfileGroup(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "SharingProfileGroupTypes"]] = None, + type: Optional[Union[str, "_models.SharingProfileGroupTypes"]] = None, ids: Optional[List[str]] = None, **kwargs ): """ :keyword type: This property allows you to specify the type of sharing group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Subscriptions** - :code:`
`:code:`
` **AADTenants**. Possible values include: "Subscriptions", - "AADTenants". + :code:`
`:code:`
` **AADTenants**. Known values are: "Subscriptions", "AADTenants". :paramtype type: str or ~azure.mgmt.compute.v2022_01_03.models.SharingProfileGroupTypes :keyword ids: A list of subscription/tenant ids the gallery is aimed to be shared to. :paramtype ids: list[str] @@ -3879,7 +3876,7 @@ class SharingStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar aggregated_state: Aggregated sharing state of current gallery. Possible values include: + :ivar aggregated_state: Aggregated sharing state of current gallery. Known values are: "Succeeded", "InProgress", "Failed", "Unknown". :vartype aggregated_state: str or ~azure.mgmt.compute.v2022_01_03.models.SharingState :ivar summary: Summary of all regional sharing status. @@ -3898,7 +3895,7 @@ class SharingStatus(msrest.serialization.Model): def __init__( self, *, - summary: Optional[List["RegionalSharingStatus"]] = None, + summary: Optional[List["_models.RegionalSharingStatus"]] = None, **kwargs ): """ @@ -3917,8 +3914,8 @@ class SharingUpdate(msrest.serialization.Model): :ivar operation_type: Required. This property allows you to specify the operation type of gallery sharing update. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` - **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Possible values - include: "Add", "Remove", "Reset", "EnableCommunity". + **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Known values + are: "Add", "Remove", "Reset", "EnableCommunity". :vartype operation_type: str or ~azure.mgmt.compute.v2022_01_03.models.SharingUpdateOperationTypes :ivar groups: A list of sharing profile groups. @@ -3937,15 +3934,15 @@ class SharingUpdate(msrest.serialization.Model): def __init__( self, *, - operation_type: Union[str, "SharingUpdateOperationTypes"], - groups: Optional[List["SharingProfileGroup"]] = None, + operation_type: Union[str, "_models.SharingUpdateOperationTypes"], + groups: Optional[List["_models.SharingProfileGroup"]] = None, **kwargs ): """ :keyword operation_type: Required. This property allows you to specify the operation type of gallery sharing update. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` - **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Possible values - include: "Add", "Remove", "Reset", "EnableCommunity". + **Add** :code:`
`:code:`
` **Remove** :code:`
`:code:`
` **Reset**. Known values + are: "Add", "Remove", "Reset", "EnableCommunity". :paramtype operation_type: str or ~azure.mgmt.compute.v2022_01_03.models.SharingUpdateOperationTypes :keyword groups: A list of sharing profile groups. @@ -4046,7 +4043,7 @@ class TargetRegion(msrest.serialization.Model): region. This property is updatable. :vartype regional_replica_count: int :ivar storage_account_type: Specifies the storage account type to be used to store the image. - This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType :ivar encryption: Optional. Allows users to provide customer managed keys for encrypting the OS @@ -4070,8 +4067,8 @@ def __init__( *, name: str, regional_replica_count: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountType"]] = None, - encryption: Optional["EncryptionImages"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountType"]] = None, + encryption: Optional["_models.EncryptionImages"] = None, **kwargs ): """ @@ -4081,7 +4078,7 @@ def __init__( region. This property is updatable. :paramtype regional_replica_count: int :keyword storage_account_type: Specifies the storage account type to be used to store the - image. This property is not updatable. Possible values include: "Standard_LRS", "Standard_ZRS", + image. This property is not updatable. Known values are: "Standard_LRS", "Standard_ZRS", "Premium_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2022_01_03.models.StorageAccountType diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/__init__.py index 336e2221f2b0..a78779994ddb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/__init__.py @@ -19,6 +19,9 @@ from ._community_gallery_images_operations import CommunityGalleryImagesOperations from ._community_gallery_image_versions_operations import CommunityGalleryImageVersionsOperations +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__ = [ 'GalleriesOperations', 'GalleryImagesOperations', @@ -33,3 +36,5 @@ 'CommunityGalleryImagesOperations', 'CommunityGalleryImageVersionsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_community_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_community_galleries_operations.py index 10f986faaf49..6821e95ed758 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_community_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_community_galleries_operations.py @@ -15,6 +15,7 @@ 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 @@ -31,9 +32,12 @@ def build_get_request( public_gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -45,42 +49,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CommunityGalleriesOperations(object): - """CommunityGalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CommunityGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s + :attr:`community_galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -88,7 +88,7 @@ def get( location: str, public_gallery_name: str, **kwargs: Any - ) -> "_models.CommunityGallery": + ) -> _models.CommunityGallery: """Get a community gallery by gallery public name. :param location: Resource location. @@ -100,13 +100,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.CommunityGallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGallery] request = build_get_request( @@ -115,11 +118,13 @@ def get( public_gallery_name=public_gallery_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_community_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_community_gallery_image_versions_operations.py index 450642e56660..2fc1f0319eb2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_community_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_community_gallery_image_versions_operations.py @@ -16,6 +16,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -50,18 +54,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -73,9 +75,12 @@ def build_list_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -88,42 +93,38 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CommunityGalleryImageVersionsOperations(object): - """CommunityGalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CommunityGalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s + :attr:`community_gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -133,7 +134,7 @@ def get( gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any - ) -> "_models.CommunityGalleryImageVersion": + ) -> _models.CommunityGalleryImageVersion: """Get a community gallery image version. :param location: Resource location. @@ -152,13 +153,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.CommunityGalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGalleryImageVersion] request = build_get_request( @@ -169,11 +173,13 @@ def get( gallery_image_version_name=gallery_image_version_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -201,7 +207,7 @@ def list( public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> Iterable["_models.CommunityGalleryImageVersionList"]: + ) -> Iterable[_models.CommunityGalleryImageVersionList]: """List community gallery image versions inside an image. :param location: Resource location. @@ -217,13 +223,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_03.models.CommunityGalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -234,9 +243,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -247,9 +258,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_community_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_community_gallery_images_operations.py index 6e50885d13fb..147bf9381e3e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_community_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_community_gallery_images_operations.py @@ -16,6 +16,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -48,18 +52,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -70,9 +72,12 @@ def build_list_request( public_gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/communityGalleries/{publicGalleryName}/images") # pylint: disable=line-too-long path_format_arguments = { @@ -84,42 +89,38 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CommunityGalleryImagesOperations(object): - """CommunityGalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CommunityGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s + :attr:`community_gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -128,7 +129,7 @@ def get( public_gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.CommunityGalleryImage": + ) -> _models.CommunityGalleryImage: """Get a community gallery image. :param location: Resource location. @@ -142,13 +143,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.CommunityGalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGalleryImage] request = build_get_request( @@ -158,11 +162,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -189,7 +195,7 @@ def list( location: str, public_gallery_name: str, **kwargs: Any - ) -> Iterable["_models.CommunityGalleryImageList"]: + ) -> Iterable[_models.CommunityGalleryImageList]: """List community gallery images inside a gallery. :param location: Resource location. @@ -203,13 +209,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_03.models.CommunityGalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CommunityGalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CommunityGalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -219,9 +228,11 @@ def prepare_request(next_link=None): public_gallery_name=public_gallery_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -231,9 +242,11 @@ def prepare_request(next_link=None): public_gallery_name=public_gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_galleries_operations.py index 62d2dafd5cb4..a5ef3de9bd98 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_galleries_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.Gallery] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,9 +128,12 @@ def build_get_request( expand: Optional[Union[str, "_models.GalleryExpandParams"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -140,22 +145,20 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, '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, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}") # pylint: disable=line-too-long path_format_arguments = { @@ -180,18 +186,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -201,9 +205,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries") # pylint: disable=line-too-long path_format_arguments = { @@ -214,18 +221,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -234,9 +239,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries") path_format_arguments = { @@ -246,58 +254,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleriesOperations(object): - """GalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s + :attr:`galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'Gallery') @@ -309,11 +316,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -346,9 +355,9 @@ def begin_create_or_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.Gallery", + gallery: _models.Gallery, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Create or update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -370,37 +379,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -417,17 +436,20 @@ def _update_initial( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> "_models.Gallery": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] + ) -> _models.Gallery: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] _json = self._serialize.body(gallery, 'GalleryUpdate') @@ -439,11 +461,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -469,9 +493,9 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - gallery: "_models.GalleryUpdate", + gallery: _models.GalleryUpdate, **kwargs: Any - ) -> LROPoller["_models.Gallery"]: + ) -> LROPoller[_models.Gallery]: """Update a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -493,37 +517,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.Gallery] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery=gallery, 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('Gallery', 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( @@ -544,7 +578,7 @@ def get( select: Optional[Union[str, "_models.SelectPermissions"]] = None, expand: Optional[Union[str, "_models.GalleryExpandParams"]] = None, **kwargs: Any - ) -> "_models.Gallery": + ) -> _models.Gallery: """Retrieves information about a Shared Image Gallery. :param resource_group_name: The name of the resource group. @@ -560,13 +594,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.Gallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Gallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Gallery] request = build_get_request( @@ -577,11 +614,13 @@ def get( select=select, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -608,13 +647,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_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 {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -623,11 +665,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_name=gallery_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -669,20 +713,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -692,8 +741,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -711,7 +766,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a resource group. :param resource_group_name: The name of the resource group. @@ -721,13 +776,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_03.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -736,9 +794,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -747,9 +807,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -786,7 +848,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.GalleryList"]: + ) -> Iterable[_models.GalleryList]: """List galleries under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -794,13 +856,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_03.models.GalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -808,9 +873,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -818,9 +885,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_application_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_application_versions_operations.py index 4101986c853f..ad62ebe76a91 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_application_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_application_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( gallery_application_name: str, gallery_application_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationVersionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +137,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +156,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -177,9 +180,12 @@ def build_delete_request_initial( gallery_application_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions/{galleryApplicationVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +199,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -216,9 +220,12 @@ def build_list_by_gallery_application_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -231,42 +238,38 @@ def build_list_by_gallery_application_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationVersionsOperations(object): - """GalleryApplicationVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s + :attr:`gallery_application_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -274,17 +277,20 @@ def _create_or_update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersion') @@ -298,11 +304,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersion", + gallery_application_version: _models.GalleryApplicationVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Create or update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -373,17 +381,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -392,20 +403,27 @@ def begin_create_or_update( 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('GalleryApplicationVersion', 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( @@ -424,17 +442,20 @@ def _update_initial( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] + ) -> _models.GalleryApplicationVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] _json = self._serialize.body(gallery_application_version, 'GalleryApplicationVersionUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,9 +503,9 @@ def begin_update( gallery_name: str, gallery_application_name: str, gallery_application_version_name: str, - gallery_application_version: "_models.GalleryApplicationVersionUpdate", + gallery_application_version: _models.GalleryApplicationVersionUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryApplicationVersion"]: + ) -> LROPoller[_models.GalleryApplicationVersion]: """Update a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -516,17 +539,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -535,20 +561,27 @@ def begin_update( 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('GalleryApplicationVersion', 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( @@ -570,7 +603,7 @@ def get( gallery_application_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryApplicationVersion": + ) -> _models.GalleryApplicationVersion: """Retrieves information about a gallery Application Version. :param resource_group_name: The name of the resource group. @@ -591,13 +624,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersion] request = build_get_request( @@ -609,11 +645,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -642,13 +680,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_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 {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -659,11 +700,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_version_name=gallery_application_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -714,22 +757,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, gallery_application_version_name=gallery_application_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -739,8 +787,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -760,7 +814,7 @@ def list_by_gallery_application( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationVersionList"]: + ) -> Iterable[_models.GalleryApplicationVersionList]: """List gallery Application Versions in a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -778,13 +832,16 @@ def list_by_gallery_application( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -795,9 +852,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=self.list_by_gallery_application.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -808,9 +867,11 @@ def prepare_request(next_link=None): gallery_application_name=gallery_application_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_applications_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_applications_operations.py index 04229ffae8d8..6b283a47eba0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_applications_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_applications_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplication] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( gallery_name: str, gallery_application_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryApplicationUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_get_request( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_application_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{galleryApplicationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -181,18 +187,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +207,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications") # pylint: disable=line-too-long path_format_arguments = { @@ -217,59 +224,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryApplicationsOperations(object): - """GalleryApplicationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s + :attr:`gallery_applications` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplication') @@ -282,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -320,9 +328,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplication", + gallery_application: _models.GalleryApplication, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Create or update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -351,17 +359,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -369,20 +380,27 @@ def begin_create_or_update( 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('GalleryApplication', 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( @@ -400,17 +418,20 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> "_models.GalleryApplication": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] + ) -> _models.GalleryApplication: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] _json = self._serialize.body(gallery_application, 'GalleryApplicationUpdate') @@ -423,11 +444,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -454,9 +477,9 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_application_name: str, - gallery_application: "_models.GalleryApplicationUpdate", + gallery_application: _models.GalleryApplicationUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryApplication"]: + ) -> LROPoller[_models.GalleryApplication]: """Update a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -484,17 +507,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryApplication] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, @@ -502,20 +528,27 @@ def begin_update( 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('GalleryApplication', 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( @@ -535,7 +568,7 @@ def get( gallery_name: str, gallery_application_name: str, **kwargs: Any - ) -> "_models.GalleryApplication": + ) -> _models.GalleryApplication: """Retrieves information about a gallery Application Definition. :param resource_group_name: The name of the resource group. @@ -551,13 +584,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.GalleryApplication :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplication"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplication] request = build_get_request( @@ -567,11 +603,13 @@ def get( gallery_application_name=gallery_application_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -599,13 +637,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_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 {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -615,11 +656,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_application_name=gallery_application_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -665,21 +708,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_application_name=gallery_application_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -689,8 +737,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -709,7 +763,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryApplicationList"]: + ) -> Iterable[_models.GalleryApplicationList]: """List gallery Application Definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -724,13 +778,16 @@ def list_by_gallery( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_03.models.GalleryApplicationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryApplicationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryApplicationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -740,9 +797,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -752,9 +811,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_image_versions_operations.py index cf7cd8e54b5d..a08cfced53cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_image_versions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersion] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( gallery_image_name: str, gallery_image_version_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageVersionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +137,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -151,20 +156,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -177,9 +180,12 @@ def build_delete_request_initial( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -193,18 +199,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -216,9 +220,12 @@ def build_list_by_gallery_image_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -231,42 +238,38 @@ def build_list_by_gallery_image_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImageVersionsOperations(object): - """GalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s + :attr:`gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -274,17 +277,20 @@ def _create_or_update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersion') @@ -298,11 +304,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersion", + gallery_image_version: _models.GalleryImageVersion, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Create or update a gallery image version. :param resource_group_name: The name of the resource group. @@ -372,17 +380,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('GalleryImageVersion', 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( @@ -423,17 +441,20 @@ def _update_initial( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> "_models.GalleryImageVersion": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] + ) -> _models.GalleryImageVersion: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] _json = self._serialize.body(gallery_image_version, 'GalleryImageVersionUpdate') @@ -447,11 +468,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -479,9 +502,9 @@ def begin_update( gallery_name: str, gallery_image_name: str, gallery_image_version_name: str, - gallery_image_version: "_models.GalleryImageVersionUpdate", + gallery_image_version: _models.GalleryImageVersionUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryImageVersion"]: + ) -> LROPoller[_models.GalleryImageVersion]: """Update a gallery image version. :param resource_group_name: The name of the resource group. @@ -514,17 +537,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersion] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -533,20 +559,27 @@ def begin_update( 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('GalleryImageVersion', 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( @@ -568,7 +601,7 @@ def get( gallery_image_version_name: str, expand: Optional[Union[str, "_models.ReplicationStatusTypes"]] = None, **kwargs: Any - ) -> "_models.GalleryImageVersion": + ) -> _models.GalleryImageVersion: """Retrieves information about a gallery image version. :param resource_group_name: The name of the resource group. @@ -588,13 +621,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersion] request = build_get_request( @@ -606,11 +642,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -639,13 +677,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_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 {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -656,11 +697,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_version_name=gallery_image_version_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -710,22 +753,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, gallery_image_version_name=gallery_image_version_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -735,8 +783,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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,7 +810,7 @@ def list_by_gallery_image( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageVersionList"]: + ) -> Iterable[_models.GalleryImageVersionList]: """List gallery image versions in a gallery image definition. :param resource_group_name: The name of the resource group. @@ -774,13 +828,16 @@ def list_by_gallery_image( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_03.models.GalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -791,9 +848,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=self.list_by_gallery_image.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -804,9 +863,11 @@ def prepare_request(next_link=None): gallery_image_name=gallery_image_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_images_operations.py index 21a1baf3639c..c46ecc98f385 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImage] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( gallery_name: str, gallery_image_name: str, *, - json: JSONType = None, + json: Optional[_models.GalleryImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -166,9 +169,12 @@ def build_delete_request_initial( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -181,18 +187,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +207,12 @@ def build_list_by_gallery_request( gallery_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images") # pylint: disable=line-too-long path_format_arguments = { @@ -217,59 +224,58 @@ def build_list_by_gallery_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class GalleryImagesOperations(object): - """GalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s + :attr:`gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImage') @@ -282,11 +288,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -320,9 +328,9 @@ def begin_create_or_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImage", + gallery_image: _models.GalleryImage, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Create or update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -349,17 +357,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -367,20 +378,27 @@ def begin_create_or_update( 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('GalleryImage', 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( @@ -398,17 +416,20 @@ def _update_initial( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> "_models.GalleryImage": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] + ) -> _models.GalleryImage: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] _json = self._serialize.body(gallery_image, 'GalleryImageUpdate') @@ -421,11 +442,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -452,9 +475,9 @@ def begin_update( resource_group_name: str, gallery_name: str, gallery_image_name: str, - gallery_image: "_models.GalleryImageUpdate", + gallery_image: _models.GalleryImageUpdate, **kwargs: Any - ) -> LROPoller["_models.GalleryImage"]: + ) -> LROPoller[_models.GalleryImage]: """Update a gallery image definition. :param resource_group_name: The name of the resource group. @@ -481,17 +504,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.GalleryImage] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, @@ -499,20 +525,27 @@ def begin_update( 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('GalleryImage', 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( @@ -532,7 +565,7 @@ def get( gallery_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.GalleryImage": + ) -> _models.GalleryImage: """Retrieves information about a gallery image definition. :param resource_group_name: The name of the resource group. @@ -547,13 +580,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.GalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImage] request = build_get_request( @@ -563,11 +599,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -595,13 +633,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_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 {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -611,11 +652,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements gallery_image_name=gallery_image_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -661,21 +704,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, gallery_image_name=gallery_image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -685,8 +733,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -705,7 +759,7 @@ def list_by_gallery( resource_group_name: str, gallery_name: str, **kwargs: Any - ) -> Iterable["_models.GalleryImageList"]: + ) -> Iterable[_models.GalleryImageList]: """List gallery image definitions in a gallery. :param resource_group_name: The name of the resource group. @@ -718,13 +772,16 @@ def list_by_gallery( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_03.models.GalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -734,9 +791,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=self.list_by_gallery.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -746,9 +805,11 @@ def prepare_request(next_link=None): gallery_name=gallery_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_sharing_profile_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_sharing_profile_operations.py index 1b99b4115617..61d05e37eb4e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_sharing_profile_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_gallery_sharing_profile_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +33,17 @@ def build_update_request_initial( resource_group_name: str, gallery_name: str, *, - json: JSONType = None, + json: Optional[_models.SharingUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/share") # pylint: disable=line-too-long path_format_arguments = { @@ -52,62 +55,61 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class GallerySharingProfileOperations(object): - """GallerySharingProfileOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GallerySharingProfileOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s + :attr:`gallery_sharing_profile` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _update_initial( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> "_models.SharingUpdate": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] + ) -> _models.SharingUpdate: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharingUpdate] _json = self._serialize.body(sharing_update, 'SharingUpdate') @@ -119,11 +121,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -153,9 +157,9 @@ def begin_update( self, resource_group_name: str, gallery_name: str, - sharing_update: "_models.SharingUpdate", + sharing_update: _models.SharingUpdate, **kwargs: Any - ) -> LROPoller["_models.SharingUpdate"]: + ) -> LROPoller[_models.SharingUpdate]: """Update sharing profile of a gallery. :param resource_group_name: The name of the resource group. @@ -177,37 +181,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_01_03.models.SharingUpdate] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharingUpdate] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharingUpdate"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, gallery_name=gallery_name, sharing_update=sharing_update, 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('SharingUpdate', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_shared_galleries_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_shared_galleries_operations.py index 5ca87202bb89..0de3182bb0bb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_shared_galleries_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_shared_galleries_operations.py @@ -16,6 +16,7 @@ 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 @@ -33,9 +34,12 @@ def build_list_request( shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries") # pylint: disable=line-too-long path_format_arguments = { @@ -46,20 +50,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 shared_to is not None: - _query_parameters['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') + _params['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -70,9 +72,12 @@ def build_get_request( gallery_unique_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}") # pylint: disable=line-too-long path_format_arguments = { @@ -84,42 +89,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class SharedGalleriesOperations(object): - """SharedGalleriesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharedGalleriesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s + :attr:`shared_galleries` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -127,7 +128,7 @@ def list( location: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> Iterable["_models.SharedGalleryList"]: + ) -> Iterable[_models.SharedGalleryList]: """List shared galleries by subscription id or tenant id. :param location: Resource location. @@ -140,13 +141,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_03.models.SharedGalleryList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -156,9 +160,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -168,9 +174,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -209,7 +217,7 @@ def get( location: str, gallery_unique_name: str, **kwargs: Any - ) -> "_models.SharedGallery": + ) -> _models.SharedGallery: """Get a shared gallery by subscription id or tenant id. :param location: Resource location. @@ -221,13 +229,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.SharedGallery :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGallery"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGallery] request = build_get_request( @@ -236,11 +247,13 @@ def get( gallery_unique_name=gallery_unique_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_shared_gallery_image_versions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_shared_gallery_image_versions_operations.py index 0daec857fd4b..63e03adcafc4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_shared_gallery_image_versions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_shared_gallery_image_versions_operations.py @@ -16,6 +16,7 @@ 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 @@ -35,9 +36,12 @@ def build_list_request( shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +54,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 shared_to is not None: - _query_parameters['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') + _params['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -76,9 +78,12 @@ def build_get_request( gallery_image_version_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}/versions/{galleryImageVersionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -92,42 +97,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class SharedGalleryImageVersionsOperations(object): - """SharedGalleryImageVersionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharedGalleryImageVersionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s + :attr:`shared_gallery_image_versions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -137,7 +138,7 @@ def list( gallery_image_name: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> Iterable["_models.SharedGalleryImageVersionList"]: + ) -> Iterable[_models.SharedGalleryImageVersionList]: """List shared gallery image versions by subscription id or tenant id. :param location: Resource location. @@ -157,13 +158,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_03.models.SharedGalleryImageVersionList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageVersionList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageVersionList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -175,9 +179,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -189,9 +195,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -232,7 +240,7 @@ def get( gallery_image_name: str, gallery_image_version_name: str, **kwargs: Any - ) -> "_models.SharedGalleryImageVersion": + ) -> _models.SharedGalleryImageVersion: """Get a shared gallery image version by subscription id or tenant id. :param location: Resource location. @@ -252,13 +260,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryImageVersion :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageVersion"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageVersion] request = build_get_request( @@ -269,11 +280,13 @@ def get( gallery_image_version_name=gallery_image_version_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_shared_gallery_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_shared_gallery_images_operations.py index ac7b4ce54f0a..b00c9d12b8cf 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_shared_gallery_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_01_03/operations/_shared_gallery_images_operations.py @@ -16,6 +16,7 @@ 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 @@ -34,9 +35,12 @@ def build_list_request( shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images") # pylint: disable=line-too-long path_format_arguments = { @@ -48,20 +52,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 shared_to is not None: - _query_parameters['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') + _params['sharedTo'] = _SERIALIZER.query("shared_to", shared_to, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -73,9 +75,12 @@ def build_get_request( gallery_image_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}/images/{galleryImageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -88,42 +93,38 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class SharedGalleryImagesOperations(object): - """SharedGalleryImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SharedGalleryImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_01_03.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_01_03.ComputeManagementClient`'s + :attr:`shared_gallery_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -132,7 +133,7 @@ def list( gallery_unique_name: str, shared_to: Optional[Union[str, "_models.SharedToValues"]] = None, **kwargs: Any - ) -> Iterable["_models.SharedGalleryImageList"]: + ) -> Iterable[_models.SharedGalleryImageList]: """List shared gallery images by subscription id or tenant id. :param location: Resource location. @@ -149,13 +150,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_01_03.models.SharedGalleryImageList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImageList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImageList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -166,9 +170,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -179,9 +185,11 @@ def prepare_request(next_link=None): api_version=api_version, shared_to=shared_to, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -221,7 +229,7 @@ def get( gallery_unique_name: str, gallery_image_name: str, **kwargs: Any - ) -> "_models.SharedGalleryImage": + ) -> _models.SharedGalleryImage: """Get a shared gallery image by subscription id or tenant id. :param location: Resource location. @@ -236,13 +244,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_01_03.models.SharedGalleryImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedGalleryImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-01-03") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-03")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SharedGalleryImage] request = build_get_request( @@ -252,11 +263,13 @@ def get( gallery_image_name=gallery_image_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/_compute_management_client.py index bea06d2f20e8..00c6d4fdf417 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/_compute_management_client.py @@ -127,32 +127,84 @@ 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.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_point_collections = RestorePointCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservation_groups = CapacityReservationGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservations = CapacityReservationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_point_collections = RestorePointCollectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_points = RestorePointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservations = CapacityReservationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/_compute_management_client.py index fbfdac255170..80c2c7d6b9a6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/_compute_management_client.py @@ -129,32 +129,84 @@ 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.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_sizes = VirtualMachineSizesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extensions = VirtualMachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images = VirtualMachineImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.availability_sets = AvailabilitySetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.proximity_placement_groups = ProximityPlacementGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_host_groups = DedicatedHostGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.dedicated_hosts = DedicatedHostsOperations(self._client, self._config, self._serialize, self._deserialize) - self.ssh_public_keys = SshPublicKeysOperations(self._client, self._config, self._serialize, self._deserialize) - self.images = ImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_point_collections = RestorePointCollectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.restore_points = RestorePointsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservation_groups = CapacityReservationGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.capacity_reservations = CapacityReservationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.log_analytics = LogAnalyticsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_sizes = VirtualMachineSizesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_sets = VirtualMachineScaleSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_extensions = VirtualMachineScaleSetExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_rolling_upgrades = VirtualMachineScaleSetRollingUpgradesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_extensions = VirtualMachineScaleSetVMExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vms = VirtualMachineScaleSetVMsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extensions = VirtualMachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images = VirtualMachineImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_images_edge_zone = VirtualMachineImagesEdgeZoneOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_extension_images = VirtualMachineExtensionImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.availability_sets = AvailabilitySetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.proximity_placement_groups = ProximityPlacementGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_host_groups = DedicatedHostGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.dedicated_hosts = DedicatedHostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.ssh_public_keys = SshPublicKeysOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.images = ImagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_point_collections = RestorePointCollectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.restore_points = RestorePointsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservation_groups = CapacityReservationGroupsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.capacity_reservations = CapacityReservationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.log_analytics = LogAnalyticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_run_commands = VirtualMachineRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_scale_set_vm_run_commands = VirtualMachineScaleSetVMRunCommandsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/__init__.py index 9e7600d93081..4d943f233924 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/__init__.py @@ -33,6 +33,9 @@ from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations from ._virtual_machine_scale_set_vm_run_commands_operations import VirtualMachineScaleSetVMRunCommandsOperations +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', 'UsageOperations', @@ -61,3 +64,5 @@ 'VirtualMachineRunCommandsOperations', 'VirtualMachineScaleSetVMRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_availability_sets_operations.py index 8ad17236b543..8d406717b943 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_availability_sets_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class AvailabilitySetsOperations: - """AvailabilitySetsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,9 +119,9 @@ async def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -131,14 +135,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -150,11 +157,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -193,13 +202,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -208,11 +220,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,7 +249,7 @@ async def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -247,13 +261,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -262,11 +279,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +311,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -305,13 +324,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +342,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,9 +355,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -371,7 +397,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.AvailabilitySetListResult"]: + ) -> AsyncIterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -383,13 +409,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -398,9 +427,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -409,9 +440,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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 +483,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -465,13 +498,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -481,9 +517,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -493,9 +531,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_capacity_reservation_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_capacity_reservation_groups_operations.py index 571d4bbe64a3..3782477a2573 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_capacity_reservation_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_capacity_reservation_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CapacityReservationGroupsOperations: - """CapacityReservationGroupsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroup", + parameters: _models.CapacityReservationGroup, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details. @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroupUpdate", + parameters: _models.CapacityReservationGroupUpdate, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. @@ -138,14 +142,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroupUpdate') @@ -157,11 +164,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -203,13 +212,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -218,11 +230,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,7 +260,7 @@ async def get( capacity_reservation_group_name: str, expand: Optional[Union[str, "_models.CapacityReservationGroupInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation that retrieves information about a capacity reservation group. :param resource_group_name: The name of the resource group. @@ -264,13 +278,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] request = build_get_request( @@ -280,11 +297,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationGroupListResult"]: + ) -> AsyncIterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -329,13 +348,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -345,9 +367,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, 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: @@ -357,9 +381,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 +423,7 @@ def list_by_subscription( self, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationGroupListResult"]: + ) -> AsyncIterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -413,13 +439,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -428,9 +457,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -439,9 +470,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_capacity_reservations_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_capacity_reservations_operations.py index 287cba1c3be6..8e265de3b740 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_capacity_reservations_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_capacity_reservations_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CapacityReservationsOperations: - """CapacityReservationsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`capacity_reservations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> "_models.CapacityReservation": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] + ) -> _models.CapacityReservation: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] _json = self._serialize.body(parameters, 'CapacityReservation') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> AsyncLROPoller["_models.CapacityReservation"]: + ) -> AsyncLROPoller[_models.CapacityReservation]: """The operation to create or update a capacity reservation. Please note some properties can be set only during capacity reservation creation. Please refer to https://aka.ms/CapacityReservation for more details. @@ -139,17 +143,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -157,20 +164,27 @@ async def begin_create_or_update( 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('CapacityReservation', 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( @@ -188,17 +202,20 @@ async def _update_initial( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> Optional["_models.CapacityReservation"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CapacityReservation"]] + ) -> Optional[_models.CapacityReservation]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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.CapacityReservation]] _json = self._serialize.body(parameters, 'CapacityReservationUpdate') @@ -211,11 +228,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -244,9 +263,9 @@ async def begin_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.CapacityReservation"]: + ) -> AsyncLROPoller[_models.CapacityReservation]: """The operation to update a capacity reservation. :param resource_group_name: The name of the resource group. @@ -271,17 +290,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -289,20 +311,27 @@ async def begin_update( 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('CapacityReservation', 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( @@ -322,13 +351,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements capacity_reservation_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -338,11 +370,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -389,21 +423,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -413,8 +452,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -435,7 +480,7 @@ async def get( capacity_reservation_name: str, expand: Optional[Union[str, "_models.CapacityReservationInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservation": + ) -> _models.CapacityReservation: """The operation that retrieves information about the capacity reservation. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.CapacityReservation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list_by_capacity_reservation_group( resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.CapacityReservationListResult"]: + ) -> AsyncIterable[_models.CapacityReservationListResult]: """Lists all of the capacity reservations in the specified capacity reservation group. Use the nextLink property in the response to get the next page of capacity reservations. @@ -517,13 +567,16 @@ def list_by_capacity_reservation_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.CapacityReservationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -533,9 +586,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_capacity_reservation_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: @@ -545,9 +600,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_dedicated_host_groups_operations.py index b9df5c09479c..5c3a46ce3e2d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_dedicated_host_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostGroupsOperations: - """DedicatedHostGroupsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -68,14 +67,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -87,11 +89,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -121,9 +125,9 @@ async def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -137,14 +141,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -156,11 +163,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -199,13 +208,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,11 +226,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +256,7 @@ async def get( host_group_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -258,13 +272,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -274,11 +291,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +323,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -317,13 +336,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -332,9 +354,11 @@ def prepare_request(next_link=None): 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: @@ -343,9 +367,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -382,7 +408,7 @@ async def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostGroupListResult"]: + ) -> AsyncIterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -393,13 +419,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -407,9 +436,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -417,9 +448,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_dedicated_hosts_operations.py index 58e577dc1a45..3d99d833792f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DedicatedHostsOperations: - """DedicatedHostsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('DedicatedHost', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DedicatedHost"]: + ) -> AsyncLROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -267,17 +286,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -285,20 +307,27 @@ async def begin_update( 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('DedicatedHost', 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( @@ -318,13 +347,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -334,11 +366,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,21 +417,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -407,8 +446,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -429,7 +474,7 @@ async def get( host_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -495,7 +545,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DedicatedHostListResult"]: + ) -> AsyncIterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -510,13 +560,16 @@ def list_by_host_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -526,9 +579,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -538,9 +593,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -580,13 +637,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -596,11 +656,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -649,21 +711,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -673,8 +740,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_images_operations.py index c442efa70fe4..aac73df40b99 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ImagesOperations: - """ImagesOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -130,37 +134,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -177,17 +191,20 @@ async def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -199,11 +216,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -233,9 +252,9 @@ async def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Image"]: + ) -> AsyncLROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -256,37 +275,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -305,13 +334,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements image_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -320,11 +352,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -366,20 +400,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -389,8 +428,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -410,7 +455,7 @@ async def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -424,13 +469,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -440,11 +488,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -470,7 +520,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -481,13 +531,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -496,9 +549,11 @@ def prepare_request(next_link=None): 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: @@ -507,9 +562,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -546,7 +603,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ImageListResult"]: + ) -> AsyncIterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -556,13 +613,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -570,9 +630,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -580,9 +642,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_log_analytics_operations.py index a50e77b09849..e0b2b3d1a59d 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,41 +25,42 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LogAnalyticsOperations: - """LogAnalyticsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -69,11 +71,13 @@ async def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -100,9 +104,9 @@ async def _export_request_rate_by_interval_initial( async def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -124,36 +128,46 @@ async def begin_export_request_rate_by_interval( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = await self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -169,17 +183,20 @@ def get_long_running_output(pipeline_response): async def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -190,11 +207,13 @@ async def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -221,9 +240,9 @@ async def _export_throttled_requests_initial( async def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> AsyncLROPoller["_models.LogAnalyticsOperationResult"]: + ) -> AsyncLROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -245,36 +264,46 @@ async def begin_export_throttled_requests( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = await self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_operations.py index 6baf026bf4ed..fc5c133b237f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> AsyncIterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,31 +57,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_proximity_placement_groups_operations.py index 663343c9fdcb..96909a9f3812 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_proximity_placement_groups_operations.py @@ -15,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 @@ -24,35 +25,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ProximityPlacementGroupsOperations: - """ProximityPlacementGroupsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -66,14 +65,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -85,11 +87,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -119,9 +123,9 @@ async def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -135,14 +139,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -154,11 +161,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -197,13 +206,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,11 +224,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,7 +254,7 @@ async def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -255,13 +269,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -271,11 +288,13 @@ async def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -300,7 +319,7 @@ async def get( def list_by_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -310,13 +329,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -324,9 +346,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -334,9 +358,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -374,7 +400,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ProximityPlacementGroupListResult"]: + ) -> AsyncIterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -386,13 +412,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -401,9 +430,11 @@ def prepare_request(next_link=None): 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: @@ -412,9 +443,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_restore_point_collections_operations.py index 1fe8fe0a9777..b8a20a8abbe4 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_restore_point_collections_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_restore_point_collections_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,35 +27,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RestorePointCollectionsOperations: - """RestorePointCollectionsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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_or_update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollection", + parameters: _models.RestorePointCollection, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. @@ -71,14 +70,17 @@ async def create_or_update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollection') @@ -90,11 +92,13 @@ async def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,9 +128,9 @@ async def update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollectionUpdate", + parameters: _models.RestorePointCollectionUpdate, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. @@ -140,14 +144,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollectionUpdate') @@ -159,11 +166,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -190,13 +199,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -205,11 +217,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_name=restore_point_collection_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -252,20 +266,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -275,8 +294,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -296,7 +321,7 @@ async def get( restore_point_collection_name: str, expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to get the restore point collection. :param resource_group_name: The name of the resource group. @@ -311,13 +336,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] request = build_get_request( @@ -327,11 +355,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -357,7 +387,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.RestorePointCollectionListResult"]: + ) -> AsyncIterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in a resource group. :param resource_group_name: The name of the resource group. @@ -369,13 +399,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -384,9 +417,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -395,9 +430,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -434,7 +471,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.RestorePointCollectionListResult"]: + ) -> AsyncIterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in the subscription. Use nextLink property in the response to get the next page of restore point collections. Do this till nextLink is not null to fetch all the restore point collections. @@ -446,13 +483,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -460,9 +500,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -470,9 +512,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_restore_points_operations.py index a81c8a38ae8b..cfc1f7acc562 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_restore_points_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_restore_points_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class RestorePointsOperations: - """RestorePointsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`restore_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_initial( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> "_models.RestorePoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] + ) -> _models.RestorePoint: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] _json = self._serialize.body(parameters, 'RestorePoint') @@ -73,11 +75,13 @@ async def _create_initial( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -104,9 +108,9 @@ async def begin_create( resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> AsyncLROPoller["_models.RestorePoint"]: + ) -> AsyncLROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. @@ -131,17 +135,20 @@ async def begin_create( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.RestorePoint] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] 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, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, @@ -149,20 +156,27 @@ async def begin_create( 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('RestorePoint', 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( @@ -182,13 +196,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -198,11 +215,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_name=restore_point_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,21 +266,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -271,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -293,7 +323,7 @@ async def get( restore_point_name: str, expand: Optional[Union[str, "_models.RestorePointExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePoint": + ) -> _models.RestorePoint: """The operation to get the restore point. :param resource_group_name: The name of the resource group. @@ -310,13 +340,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] request = build_get_request( @@ -327,11 +360,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_ssh_public_keys_operations.py index cdc9fd8d64e2..8f61f0924113 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_ssh_public_keys_operations.py @@ -15,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 @@ -24,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SshPublicKeysOperations: - """SshPublicKeysOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -60,13 +59,16 @@ def list_by_subscription( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -74,9 +76,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -84,9 +88,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -124,7 +130,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SshPublicKeysGroupListResult"]: + ) -> AsyncIterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -137,13 +143,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -152,9 +161,11 @@ def prepare_request(next_link=None): 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: @@ -163,9 +174,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -203,9 +216,9 @@ async def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -219,14 +232,17 @@ async def create( :rtype: ~azure.mgmt.compute.v2022_03_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -238,11 +254,13 @@ async def create( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -272,9 +290,9 @@ async def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -288,14 +306,17 @@ async def update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -307,11 +328,13 @@ async def update( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -350,13 +373,16 @@ async def delete( # pylint: disable=inconsistent-return-statements :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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -365,11 +391,13 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,7 +420,7 @@ async def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -404,13 +432,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -419,11 +450,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,7 +483,7 @@ async def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -464,13 +497,16 @@ async def generate_key_pair( :rtype: ~azure.mgmt.compute.v2022_03_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -479,11 +515,13 @@ async def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_usage_operations.py index c7a5c859a89b..a0a78de565c1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_usage_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUsagesResult"]: + ) -> AsyncIterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -61,13 +60,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -76,9 +78,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -87,9 +91,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_extension_images_operations.py index e7b4b0975898..13831a285127 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_extension_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionImagesOperations: - """VirtualMachineExtensionImagesOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +50,7 @@ async def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -67,13 +66,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -84,11 +86,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -115,7 +119,7 @@ async def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -127,13 +131,16 @@ async def list_types( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -142,11 +149,13 @@ async def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -177,7 +186,7 @@ async def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -197,13 +206,16 @@ async def list_versions( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -216,11 +228,13 @@ async def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_extensions_operations.py index b3b9c8ed494b..95a42aaca294 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,43 +25,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineExtensionsOperations: - """VirtualMachineExtensionsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -108,9 +112,9 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -137,17 +141,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -155,20 +162,27 @@ async def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -186,17 +200,20 @@ async def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -209,11 +226,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -240,9 +259,9 @@ async def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -269,17 +288,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -287,20 +309,27 @@ async def begin_update( 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('VirtualMachineExtension', 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( @@ -320,13 +349,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -336,11 +368,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -385,21 +419,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -409,8 +448,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -431,7 +476,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -447,13 +492,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -464,11 +512,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -496,7 +546,7 @@ async def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -510,13 +560,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -526,11 +579,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_images_edge_zone_operations.py index 4490d4986588..48dd0308bf88 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_images_edge_zone_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesEdgeZoneOperations: - """VirtualMachineImagesEdgeZoneOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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 +52,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. @@ -73,13 +72,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -92,11 +94,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -129,7 +133,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. @@ -156,13 +160,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -177,11 +184,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -209,7 +218,7 @@ async def list_offers( edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. @@ -224,13 +233,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -240,11 +252,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -271,7 +285,7 @@ async def list_publishers( location: str, edge_zone: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. @@ -283,13 +297,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -298,11 +315,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -331,7 +350,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. @@ -348,13 +367,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -365,11 +387,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_images_operations.py index f08d45d213d7..65526f546626 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_images_operations.py @@ -13,6 +13,7 @@ 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 @@ -22,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineImagesOperations: - """VirtualMachineImagesOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -52,7 +51,7 @@ async def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -70,13 +69,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -88,11 +90,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -124,7 +128,7 @@ async def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -147,13 +151,16 @@ async def list( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -167,11 +174,13 @@ async def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -198,7 +207,7 @@ async def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -210,13 +219,16 @@ async def list_offers( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -225,11 +237,13 @@ async def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,7 +269,7 @@ async def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -265,13 +279,16 @@ async def list_publishers( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -279,11 +296,13 @@ async def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -311,7 +330,7 @@ async def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -325,13 +344,16 @@ async def list_skus( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -341,11 +363,13 @@ async def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -372,7 +396,7 @@ async def list_by_edge_zone( location: str, edge_zone: str, **kwargs: Any - ) -> "_models.VmImagesInEdgeZoneListResult": + ) -> _models.VmImagesInEdgeZoneListResult: """Gets a list of all virtual machine image versions for the specified edge zone. :param location: The name of a supported Azure region. @@ -384,13 +408,16 @@ async def list_by_edge_zone( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VmImagesInEdgeZoneListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VmImagesInEdgeZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VmImagesInEdgeZoneListResult] request = build_list_by_edge_zone_request( @@ -399,11 +426,13 @@ async def list_by_edge_zone( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_edge_zone.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_run_commands_operations.py index 294aa8832322..7002c212dba7 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineRunCommandsOperations: - """VirtualMachineRunCommandsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.RunCommandListResult"]: + ) -> AsyncIterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -64,13 +63,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -131,7 +137,7 @@ async def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -143,13 +149,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -158,11 +167,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,18 +199,21 @@ async def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -212,11 +226,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,11 +263,11 @@ async def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -263,7 +279,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -280,16 +296,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -297,20 +316,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -328,18 +354,21 @@ async def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -352,11 +381,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -383,11 +414,11 @@ async def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -398,7 +429,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -415,16 +446,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -432,20 +466,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -465,13 +506,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -481,11 +525,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,21 +576,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -554,8 +605,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -576,7 +633,7 @@ async def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -592,13 +649,16 @@ async def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -609,11 +669,13 @@ async def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -641,7 +703,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -657,13 +719,16 @@ def list_by_virtual_machine( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -674,9 +739,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -687,9 +754,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py index ed94ea5b767b..f281d4692450 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetExtensionsOperations: - """VirtualMachineScaleSetExtensionsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -110,9 +114,9 @@ async def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -140,17 +144,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -158,20 +165,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -189,17 +203,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -212,11 +229,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -247,9 +266,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -276,17 +295,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -294,20 +316,27 @@ async def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -327,13 +356,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -343,11 +375,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -392,21 +426,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -416,8 +455,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -438,7 +483,7 @@ async def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -454,13 +499,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -471,11 +519,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,7 +552,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -516,13 +566,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -532,9 +585,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -544,9 +599,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index 48e89b909d51..c5ccea9337b0 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetRollingUpgradesOperations: - """VirtualMachineScaleSetRollingUpgradesOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -51,13 +50,16 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -66,11 +68,13 @@ async def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -112,20 +116,25 @@ async def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._cancel_initial( + raw_result = await self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -135,8 +144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -155,13 +170,16 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat vm_scale_set_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -170,11 +188,13 @@ async def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-stat subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -218,20 +238,25 @@ async def begin_start_os_upgrade( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._start_os_upgrade_initial( + raw_result = await self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -241,8 +266,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -261,13 +292,16 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu vm_scale_set_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -276,11 +310,13 @@ async def _start_extension_upgrade_initial( # pylint: disable=inconsistent-retu subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,20 +360,25 @@ async def begin_start_extension_upgrade( # pylint: disable=inconsistent-return- :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._start_extension_upgrade_initial( + raw_result = await self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -347,8 +388,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -367,7 +414,7 @@ async def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -379,13 +426,16 @@ async def get_latest( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -394,11 +444,13 @@ async def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py index c4cbf5de5522..0665f6b402be 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,6 +14,7 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling @@ -24,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMExtensionsOperations: - """VirtualMachineScaleSetVMExtensionsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -51,17 +50,20 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -75,11 +77,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -111,9 +115,9 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -142,17 +146,20 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -161,20 +168,27 @@ async def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -193,17 +207,20 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -217,11 +234,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -249,9 +268,9 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -280,17 +299,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -299,20 +321,27 @@ async def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -333,13 +362,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -350,11 +382,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -402,22 +436,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -427,8 +466,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -450,7 +495,7 @@ async def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -468,13 +513,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -486,11 +534,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -519,7 +569,7 @@ async def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -535,13 +585,16 @@ async def list( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -552,11 +605,13 @@ async def list( api_version=api_version, 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 - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index b061e561de9f..ccfd88064b2b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMRunCommandsOperations: - """VirtualMachineScaleSetVMRunCommandsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, @@ -53,18 +52,21 @@ async def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -78,11 +80,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -114,11 +118,11 @@ async def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -131,7 +135,7 @@ async def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -148,16 +152,19 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -166,20 +173,27 @@ async def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -198,18 +212,21 @@ async def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -223,11 +240,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -255,11 +274,11 @@ async def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineRunCommand"]: + ) -> AsyncLROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -272,7 +291,7 @@ async def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -289,16 +308,19 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -307,20 +329,27 @@ async def begin_update( 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('VirtualMachineRunCommand', 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( @@ -341,13 +370,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -358,11 +390,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -410,22 +444,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -435,8 +474,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -458,7 +503,7 @@ async def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -476,13 +521,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_request( @@ -494,11 +542,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -527,7 +577,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> AsyncIterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -545,13 +595,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -563,9 +616,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -577,9 +632,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_vms_operations.py index 7e9cd8df071e..b5e912804c47 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,43 +27,44 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetVMsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -78,11 +80,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -105,7 +109,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -132,17 +136,20 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -150,6 +157,8 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -159,8 +168,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -180,13 +195,16 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -196,11 +214,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -246,21 +266,26 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -270,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -291,13 +322,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -307,11 +341,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -358,21 +394,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -382,8 +423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -401,17 +448,20 @@ async def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -424,11 +474,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -459,9 +511,9 @@ async def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -487,17 +539,20 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -505,20 +560,27 @@ async def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -539,13 +601,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -556,11 +621,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -609,22 +676,27 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -634,8 +706,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -656,7 +734,7 @@ async def get( instance_id: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -674,13 +752,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -691,11 +772,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -723,7 +806,7 @@ async def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -737,13 +820,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -753,11 +839,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -787,7 +875,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -811,13 +899,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -830,9 +921,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -845,9 +938,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -888,13 +983,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -905,11 +1003,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -961,22 +1061,27 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -986,8 +1091,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1007,13 +1118,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1023,11 +1137,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1072,21 +1188,26 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1096,8 +1217,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1117,13 +1244,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1133,11 +1263,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1182,21 +1314,26 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1206,8 +1343,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1227,13 +1370,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1243,11 +1389,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1293,21 +1441,26 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1317,8 +1470,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1339,7 +1498,7 @@ async def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -1358,13 +1517,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1375,11 +1537,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1407,13 +1571,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s instance_id: 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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -1423,11 +1590,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1472,21 +1641,26 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1496,8 +1670,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1531,13 +1711,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -1547,11 +1730,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1573,18 +1758,21 @@ async def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -1597,11 +1785,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1630,11 +1820,11 @@ async def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -1645,7 +1835,7 @@ async def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2022_03_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -1662,16 +1852,19 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1679,20 +1872,27 @@ async def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_sets_operations.py index 4075881111b0..486f4f257bdb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineScaleSetsOperations: # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -151,11 +160,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -185,9 +196,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -210,37 +221,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -257,17 +278,20 @@ async def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -279,11 +303,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +335,9 @@ async def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineScaleSet"]: + ) -> AsyncLROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -334,37 +360,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -384,13 +420,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -400,11 +439,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -450,21 +491,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -474,8 +520,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -495,7 +547,7 @@ async def get( vm_scale_set_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -511,13 +563,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -527,11 +582,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -556,17 +613,20 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -581,11 +641,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -607,7 +669,7 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -634,23 +696,28 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -660,8 +727,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -678,18 +751,21 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -702,11 +778,13 @@ async def _delete_instances_initial( # pylint: disable=inconsistent-return-stat json=_json, force_deletion=force_deletion, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -728,7 +806,7 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: @@ -756,17 +834,20 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_instances_initial( + raw_result = await self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, @@ -774,6 +855,8 @@ async def begin_delete_instances( # pylint: disable=inconsistent-return-stateme api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -783,8 +866,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -803,7 +892,7 @@ async def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -815,13 +904,16 @@ async def get_instance_view( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -830,11 +922,13 @@ async def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -860,7 +954,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -872,13 +966,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -887,9 +984,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -898,9 +997,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -937,7 +1038,7 @@ async def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -949,13 +1050,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -963,9 +1067,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -973,9 +1079,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1014,7 +1122,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1029,13 +1137,16 @@ def list_skus( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1045,9 +1156,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1057,9 +1170,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1098,7 +1213,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> AsyncIterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1112,13 +1227,16 @@ def get_os_upgrade_history( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1128,9 +1246,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1140,9 +1260,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1180,17 +1302,20 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1206,11 +1331,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1233,7 +1360,7 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -1264,17 +1391,20 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -1282,6 +1412,8 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1291,8 +1423,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1309,17 +1447,20 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1334,11 +1475,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1360,7 +1503,7 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -1385,23 +1528,28 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1411,8 +1559,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1429,17 +1583,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1454,11 +1611,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1480,7 +1639,7 @@ async def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -1505,23 +1664,28 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1531,8 +1695,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1549,17 +1719,20 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1574,11 +1747,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1600,7 +1775,7 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -1626,23 +1801,28 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1652,8 +1832,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1670,17 +1856,20 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1695,11 +1884,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1721,7 +1912,7 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -1749,23 +1940,28 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1775,8 +1971,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1793,17 +1995,20 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1815,11 +2020,13 @@ async def _update_instances_initial( # pylint: disable=inconsistent-return-stat content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1841,7 +2048,7 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> AsyncLROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -1865,23 +2072,28 @@ async def begin_update_instances( # pylint: disable=inconsistent-return-stateme :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_instances_initial( + raw_result = await self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1891,8 +2103,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1909,17 +2127,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -1934,11 +2155,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1960,7 +2183,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -1986,23 +2209,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2012,8 +2240,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2030,17 +2264,20 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2055,11 +2292,13 @@ async def _reimage_all_initial( # pylint: disable=inconsistent-return-statement content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2081,7 +2320,7 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -2107,23 +2346,28 @@ async def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._reimage_all_initial( + raw_result = await self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2133,8 +2377,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2156,7 +2406,7 @@ async def force_recovery_service_fabric_platform_update_domain_walk( zone: Optional[str] = None, placement_group_id: Optional[str] = None, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -2178,13 +2428,16 @@ async def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -2196,11 +2449,13 @@ async def force_recovery_service_fabric_platform_update_domain_walk( zone=zone, placement_group_id=placement_group_id, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2226,7 +2481,7 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -2243,14 +2498,17 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret :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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -2262,11 +2520,13 @@ async def convert_to_single_placement_group( # pylint: disable=inconsistent-ret content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2287,17 +2547,20 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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(parameters, 'OrchestrationServiceStateInput') @@ -2309,11 +2572,13 @@ async def _set_orchestration_service_state_initial( # pylint: disable=inconsist content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2335,7 +2600,7 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> AsyncLROPoller[None]: """Changes ServiceState property for a given service. @@ -2358,23 +2623,28 @@ async def begin_set_orchestration_service_state( # pylint: disable=inconsistent :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._set_orchestration_service_state_initial( + raw_result = await self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -2384,8 +2654,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_sizes_operations.py index 343fef75abdc..6e784927e58f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machine_sizes_operations.py @@ -14,6 +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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachineSizesOperations: - """VirtualMachineSizesOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -62,13 +61,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -77,9 +79,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -88,9 +92,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machines_operations.py index c79f82f2f091..598729c55bd3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/aio/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class VirtualMachinesOperations: # pylint: disable=too-many-public-methods - """VirtualMachinesOperations async operations. - - You 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.aio.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -64,13 +63,16 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -79,9 +81,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -90,9 +94,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -129,17 +135,20 @@ async def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -151,11 +160,13 @@ async def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -183,9 +194,9 @@ async def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineCaptureResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -209,37 +220,47 @@ async def begin_capture( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = await self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -256,17 +277,20 @@ async def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -278,11 +302,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -312,9 +338,9 @@ async def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -338,37 +364,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -385,17 +421,20 @@ async def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -407,11 +446,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -437,9 +478,9 @@ async def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -462,37 +503,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -512,13 +563,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -528,11 +582,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -578,21 +634,26 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -602,8 +663,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -623,7 +690,7 @@ async def get( vm_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. @@ -641,13 +708,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -657,11 +727,13 @@ async def get( 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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -688,7 +760,7 @@ async def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -700,13 +772,16 @@ async def instance_view( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -715,11 +790,13 @@ async def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -746,13 +823,16 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret vm_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -761,11 +841,13 @@ async def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-ret subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -808,20 +890,25 @@ async def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._convert_to_managed_disks_initial( + raw_result = await self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -831,8 +918,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -852,13 +945,16 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements hibernate: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -868,11 +964,13 @@ async def _deallocate_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, hibernate=hibernate, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -919,21 +1017,26 @@ async def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._deallocate_initial( + raw_result = await self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, hibernate=hibernate, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -943,8 +1046,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -980,13 +1089,16 @@ async def generalize( # pylint: disable=inconsistent-return-statements :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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -995,11 +1107,13 @@ async def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1022,7 +1136,7 @@ def list( resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -1040,13 +1154,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1056,9 +1173,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -1068,9 +1187,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -1109,7 +1230,7 @@ def list_all( status_only: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineListResult"]: + ) -> AsyncIterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -1128,13 +1249,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1144,9 +1268,11 @@ def prepare_request(next_link=None): status_only=status_only, filter=filter, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1156,9 +1282,11 @@ def prepare_request(next_link=None): status_only=status_only, 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 @@ -1197,7 +1325,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineSizeListResult"]: + ) -> AsyncIterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -1212,13 +1340,16 @@ def list_available_sizes( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1228,9 +1359,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1240,9 +1373,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1282,13 +1417,16 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1298,11 +1436,13 @@ async def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1350,21 +1490,26 @@ async def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._power_off_initial( + raw_result = await self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1374,8 +1519,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1394,13 +1545,16 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -1409,11 +1563,13 @@ async def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1455,20 +1611,25 @@ async def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._reapply_initial( + raw_result = await self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1478,8 +1639,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1498,13 +1665,16 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1513,11 +1683,13 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1559,20 +1731,25 @@ async def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1582,8 +1759,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1602,13 +1785,16 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements vm_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1617,11 +1803,13 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1663,20 +1851,25 @@ async def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1686,8 +1879,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1706,13 +1905,16 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1721,11 +1923,13 @@ async def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1767,20 +1971,25 @@ async def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._redeploy_initial( + raw_result = await self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1790,8 +1999,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1808,17 +2023,20 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -1833,11 +2051,13 @@ async def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1859,7 +2079,7 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -1883,23 +2103,28 @@ async def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._reimage_initial( + raw_result = await self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -1909,8 +2134,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1930,7 +2161,7 @@ async def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -1946,13 +2177,16 @@ async def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -1962,11 +2196,13 @@ async def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1993,13 +2229,16 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s vm_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2008,11 +2247,13 @@ async def _perform_maintenance_initial( # pylint: disable=inconsistent-return-s subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2054,20 +2295,25 @@ async def begin_perform_maintenance( # pylint: disable=inconsistent-return-stat :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._perform_maintenance_initial( + raw_result = await self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2077,8 +2323,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2109,13 +2361,16 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2124,11 +2379,13 @@ async def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2150,14 +2407,17 @@ async def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -2166,11 +2426,13 @@ async def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2199,7 +2461,7 @@ async def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -2220,34 +2482,44 @@ async def begin_assess_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = await self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -2264,17 +2536,20 @@ async def _install_patches_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineInstallPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineInstallPatchesResult"]] + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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.VirtualMachineInstallPatchesResult]] _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') @@ -2286,11 +2561,13 @@ async def _install_patches_initial( content_type=content_type, json=_json, template_url=self._install_patches_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2318,9 +2595,9 @@ async def begin_install_patches( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineInstallPatchesResult"]: + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. @@ -2344,37 +2621,47 @@ async def begin_install_patches( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineInstallPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstallPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstallPatchesResult"] 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._install_patches_initial( + raw_result = await self._install_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineInstallPatchesResult', 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( @@ -2391,18 +2678,21 @@ async def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2414,11 +2704,13 @@ async def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2446,11 +2738,11 @@ async def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.RunCommandResult"]: + ) -> AsyncLROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -2459,7 +2751,7 @@ async def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2022_03_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2476,36 +2768,46 @@ async def begin_run_command( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = await self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/__init__.py index d337b3c9bc41..249b229ddd9a 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/__init__.py @@ -328,7 +328,9 @@ WindowsVMGuestPatchAutomaticByPlatformRebootSetting, WindowsVMGuestPatchMode, ) - +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__ = [ 'AdditionalCapabilities', 'AdditionalUnattendContent', @@ -649,3 +651,5 @@ 'WindowsVMGuestPatchAutomaticByPlatformRebootSetting', 'WindowsVMGuestPatchMode', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/_compute_management_client_enums.py index ed4365b70071..a8dee5bc4545 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/_compute_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ArchitectureTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ArchitectureTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the Architecture Type """ X64 = "x64" ARM64 = "Arm64" -class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilitySetSkuTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the sku of an Availability Set. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'. """ @@ -26,7 +25,7 @@ class AvailabilitySetSkuTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CLASSIC = "Classic" ALIGNED = "Aligned" -class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CachingTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard @@ -37,15 +36,15 @@ class CachingTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class CapacityReservationGroupInstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CapacityReservationGroupInstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" -class CapacityReservationInstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CapacityReservationInstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" -class ConsistencyModeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ConsistencyModeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ConsistencyMode of the RestorePoint. Can be specified in the input while creating a restore point. For now, only CrashConsistent is accepted as a valid input. Please refer to https://aka.ms/RestorePoints for more details. @@ -55,7 +54,7 @@ class ConsistencyModeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_SYSTEM_CONSISTENT = "FileSystemConsistent" APPLICATION_CONSISTENT = "ApplicationConsistent" -class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DedicatedHostLicenseTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the software license type that will be applied to the VMs deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` @@ -66,20 +65,20 @@ class DedicatedHostLicenseTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu WINDOWS_SERVER_HYBRID = "Windows_Server_Hybrid" WINDOWS_SERVER_PERPETUAL = "Windows_Server_Perpetual" -class DeleteOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DeleteOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify what happens to the network interface when the VM is deleted """ DELETE = "Delete" DETACH = "Detach" -class DiffDiskOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk option for operating system disk. """ LOCAL = "Local" -class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiffDiskPlacement(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the ephemeral disk placement for operating system disk. This property can be used by user in the request to choose the location i.e, cache disk or resource disk space for Ephemeral OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer @@ -92,7 +91,7 @@ class DiffDiskPlacement(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CACHE_DISK = "CacheDisk" RESOURCE_DISK = "ResourceDisk" -class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies how the virtual machine should be created.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.:code:`
`:code:`
` **FromImage** \u2013 @@ -105,7 +104,7 @@ class DiskCreateOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EMPTY = "Empty" ATTACH = "Attach" -class DiskDeleteOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskDeleteOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the behavior of the managed disk when the VM gets deleted i.e whether the managed disk is deleted or detached. Supported values::code:`
`:code:`
` **Delete** If this value is used, the managed disk is deleted when VM gets deleted.:code:`
`:code:`
` **Detach** @@ -116,7 +115,7 @@ class DiskDeleteOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DELETE = "Delete" DETACH = "Detach" -class DiskDetachOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskDetachOptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the detach behavior to be used while detaching a disk or which is already in the process of detachment from the virtual machine. Supported values: **ForceDetach**. :code:`
`:code:`
` detachOption: **ForceDetach** is applicable only for managed data @@ -130,7 +129,7 @@ class DiskDetachOptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FORCE_DETACH = "ForceDetach" -class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExecutionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Script execution status. """ @@ -142,41 +141,41 @@ class ExecutionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TIMED_OUT = "TimedOut" CANCELED = "Canceled" -class ExpandTypesForGetCapacityReservationGroups(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpandTypesForGetCapacityReservationGroups(str, Enum, metaclass=CaseInsensitiveEnumMeta): VIRTUAL_MACHINE_SCALE_SET_VMS_REF = "virtualMachineScaleSetVMs/$ref" VIRTUAL_MACHINES_REF = "virtualMachines/$ref" -class ExpandTypesForGetVMScaleSets(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpandTypesForGetVMScaleSets(str, Enum, metaclass=CaseInsensitiveEnumMeta): USER_DATA = "userData" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class HyperVGenerationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type associated with a resource """ V1 = "V1" V2 = "V2" -class HyperVGenerationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGenerationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the HyperVGeneration Type """ V1 = "V1" V2 = "V2" -class InstanceViewTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" USER_DATA = "userData" -class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IntervalInMins(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Interval value in minutes used to create LogAnalytics call rate logs. """ @@ -185,7 +184,7 @@ class IntervalInMins(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): THIRTY_MINS = "ThirtyMins" SIXTY_MINS = "SixtyMins" -class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -194,7 +193,7 @@ class IPVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class IPVersions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IPVersions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values are: 'IPv4' and 'IPv6'. @@ -203,7 +202,7 @@ class IPVersions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): I_PV4 = "IPv4" I_PV6 = "IPv6" -class LinuxPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinuxPatchAssessmentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` @@ -214,7 +213,7 @@ class LinuxPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class LinuxVMGuestPatchAutomaticByPlatformRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinuxVMGuestPatchAutomaticByPlatformRebootSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the reboot setting for all AutomaticByPlatform patch installation operations. """ @@ -223,7 +222,7 @@ class LinuxVMGuestPatchAutomaticByPlatformRebootSetting(with_metaclass(CaseInsen NEVER = "Never" ALWAYS = "Always" -class LinuxVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LinuxVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's @@ -235,7 +234,7 @@ class LinuxVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceOperationResultCodeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Last Maintenance Operation Result Code. """ @@ -244,14 +243,14 @@ class MaintenanceOperationResultCodeTypes(with_metaclass(CaseInsensitiveEnumMeta MAINTENANCE_ABORTED = "MaintenanceAborted" MAINTENANCE_COMPLETED = "MaintenanceCompleted" -class NetworkApiVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations """ TWO_THOUSAND_TWENTY11_01 = "2020-11-01" -class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemStateTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The OS State. """ @@ -260,14 +259,14 @@ class OperatingSystemStateTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: Specialized image. Contains already provisioned OS Disk. SPECIALIZED = "Specialized" -class OperatingSystemType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux** @@ -276,21 +275,21 @@ class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WINDOWS = "Windows" LINUX = "Linux" -class OrchestrationMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the orchestration mode for the virtual machine scale set. """ UNIFORM = "Uniform" FLEXIBLE = "Flexible" -class OrchestrationServiceNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The name of the service. """ AUTOMATIC_REPAIRS = "AutomaticRepairs" DUMMY_ORCHESTRATION_SERVICE_NAME = "DummyOrchestrationServiceName" -class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current state of the service. """ @@ -298,21 +297,21 @@ class OrchestrationServiceState(with_metaclass(CaseInsensitiveEnumMeta, str, Enu RUNNING = "Running" SUSPENDED = "Suspended" -class OrchestrationServiceStateAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OrchestrationServiceStateAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The action to be performed. """ RESUME = "Resume" SUSPEND = "Suspend" -class PatchAssessmentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchAssessmentState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the availability of a given patch. """ UNKNOWN = "Unknown" AVAILABLE = "Available" -class PatchInstallationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchInstallationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the patch after the installation operation completed. """ @@ -323,7 +322,7 @@ class PatchInstallationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) NOT_SELECTED = "NotSelected" PENDING = "Pending" -class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", or "CompletedWithWarnings." @@ -335,7 +334,7 @@ class PatchOperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" -class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProtocolTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible values are: :code:`
`\ **http** :code:`
`:code:`
` **https** """ @@ -343,7 +342,7 @@ class ProtocolTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): HTTP = "Http" HTTPS = "Https" -class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProximityPlacementGroupType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For future use. @@ -352,28 +351,28 @@ class ProximityPlacementGroupType(with_metaclass(CaseInsensitiveEnumMeta, str, E STANDARD = "Standard" ULTRA = "Ultra" -class PublicIPAddressSkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAddressSkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify public IP sku name """ BASIC = "Basic" STANDARD = "Standard" -class PublicIPAddressSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAddressSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify public IP sku tier """ REGIONAL = "Regional" GLOBAL_ENUM = "Global" -class PublicIPAllocationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicIPAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specify the public IP allocation type """ DYNAMIC = "Dynamic" STATIC = "Static" -class RepairAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RepairAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of repair action (replace, restart, reimage) that will be used for repairing unhealthy virtual machines in the scale set. Default value is replace. """ @@ -382,7 +381,7 @@ class RepairAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESTART = "Restart" REIMAGE = "Reimage" -class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale set. @@ -393,22 +392,22 @@ class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RestorePointCollectionExpandOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RestorePointCollectionExpandOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): RESTORE_POINTS = "restorePoints" -class RestorePointExpandOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RestorePointExpandOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): INSTANCE_VIEW = "instanceView" -class RollingUpgradeActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The last action performed on the rolling upgrade. """ START = "Start" CANCEL = "Cancel" -class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RollingUpgradeStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -417,7 +416,7 @@ class RollingUpgradeStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum COMPLETED = "Completed" FAULTED = "Faulted" -class SecurityEncryptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SecurityEncryptionTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the EncryptionType of the managed disk. :code:`
` It is set to DiskWithVMGuestState for encryption of the managed disk along with VMGuestState blob, and VMGuestStateOnly for encryption of just the VMGuestState blob. :code:`
`:code:`
` NOTE: @@ -427,7 +426,7 @@ class SecurityEncryptionTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) VM_GUEST_STATE_ONLY = "VMGuestStateOnly" DISK_WITH_VM_GUEST_STATE = "DiskWithVMGuestState" -class SecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the SecurityType of the virtual machine. It has to be set to any specified value to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not be enabled unless this property is set. @@ -436,7 +435,7 @@ class SecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TRUSTED_LAUNCH = "TrustedLaunch" CONFIDENTIAL_VM = "ConfidentialVM" -class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SettingNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. """ @@ -444,7 +443,7 @@ class SettingNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTO_LOGON = "AutoLogon" FIRST_LOGON_COMMANDS = "FirstLogonCommands" -class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level code. """ @@ -452,7 +451,7 @@ class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the storage account type for the managed disk. Managed OS disk storage account type can only be set when you create the scale set. NOTE: UltraSSD_LRS can only be used with data disks. It cannot be used with OS Disk. Standard_LRS uses Standard HDD. StandardSSD_LRS uses @@ -471,7 +470,7 @@ class StorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_SSD_ZRS = "StandardSSD_ZRS" PREMIUM_V2_LRS = "PremiumV2_LRS" -class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of an upgrade to virtual machines in the scale set.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade @@ -483,7 +482,7 @@ class UpgradeMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" ROLLING = "Rolling" -class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeOperationInvoker(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Invoker of the Upgrade Operation """ @@ -491,7 +490,7 @@ class UpgradeOperationInvoker(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) USER = "User" PLATFORM = "Platform" -class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UpgradeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Code indicating the current status of the upgrade. """ @@ -500,14 +499,14 @@ class UpgradeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COMPLETED = "Completed" FAULTED = "Faulted" -class VirtualMachineEvictionPolicyTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineEvictionPolicyTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the eviction policy for the Azure Spot VM/VMSS """ DEALLOCATE = "Deallocate" DELETE = "Delete" -class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachinePriorityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the priority for a standalone virtual machine or the virtual machines in the scale set. :code:`
`:code:`
` 'Low' enum will be deprecated in the future, please use 'Spot' as the enum to deploy Azure Spot VM/VMSS. @@ -517,20 +516,20 @@ class VirtualMachinePriorityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, E LOW = "Low" SPOT = "Spot" -class VirtualMachineScaleSetScaleInRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetScaleInRules(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "Default" OLDEST_VM = "OldestVM" NEWEST_VM = "NewestVM" -class VirtualMachineScaleSetSkuScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineScaleSetSkuScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The scale type applicable to the sku. """ AUTOMATIC = "Automatic" NONE = "None" -class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VirtualMachineSizeTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the size of the virtual machine. :code:`
`:code:`
` The enum data type is currently deprecated and will be removed by December 23rd 2023. :code:`
`:code:`
` Recommended way to get the list of available sizes is using these APIs: @@ -712,20 +711,20 @@ class VirtualMachineSizeTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) STANDARD_NV12 = "Standard_NV12" STANDARD_NV24 = "Standard_NV24" -class VmDiskTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VmDiskTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """VM disk types which are disallowed. """ NONE = "None" UNMANAGED = "Unmanaged" -class VMGuestPatchClassificationLinux(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchClassificationLinux(str, Enum, metaclass=CaseInsensitiveEnumMeta): CRITICAL = "Critical" SECURITY = "Security" OTHER = "Other" -class VMGuestPatchClassificationWindows(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchClassificationWindows(str, Enum, metaclass=CaseInsensitiveEnumMeta): CRITICAL = "Critical" SECURITY = "Security" @@ -736,7 +735,7 @@ class VMGuestPatchClassificationWindows(with_metaclass(CaseInsensitiveEnumMeta, TOOLS = "Tools" UPDATES = "Updates" -class VMGuestPatchRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes the reboot requirements of the patch. """ @@ -745,7 +744,7 @@ class VMGuestPatchRebootBehavior(with_metaclass(CaseInsensitiveEnumMeta, str, En ALWAYS_REQUIRES_REBOOT = "AlwaysRequiresReboot" CAN_REQUEST_REBOOT = "CanRequestReboot" -class VMGuestPatchRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines when it is acceptable to reboot a VM during a software update operation. """ @@ -753,7 +752,7 @@ class VMGuestPatchRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enu NEVER = "Never" ALWAYS = "Always" -class VMGuestPatchRebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class VMGuestPatchRebootStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reboot state of the VM following completion of the operation. """ @@ -764,7 +763,7 @@ class VMGuestPatchRebootStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" COMPLETED = "Completed" -class WindowsPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WindowsPatchAssessmentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest patch assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` @@ -775,7 +774,7 @@ class WindowsPatchAssessmentMode(with_metaclass(CaseInsensitiveEnumMeta, str, En IMAGE_DEFAULT = "ImageDefault" AUTOMATIC_BY_PLATFORM = "AutomaticByPlatform" -class WindowsVMGuestPatchAutomaticByPlatformRebootSetting(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WindowsVMGuestPatchAutomaticByPlatformRebootSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the reboot setting for all AutomaticByPlatform patch installation operations. """ @@ -784,7 +783,7 @@ class WindowsVMGuestPatchAutomaticByPlatformRebootSetting(with_metaclass(CaseIns NEVER = "Never" ALWAYS = "Always" -class WindowsVMGuestPatchMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class WindowsVMGuestPatchMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual machines associated to virtual machine scale set with OrchestrationMode as Flexible.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/_models_py3.py index f7fc767351ee..5eccaeaf8c8f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AdditionalCapabilities(msrest.serialization.Model): @@ -64,7 +66,7 @@ class AdditionalUnattendContent(msrest.serialization.Model): "Microsoft-Windows-Shell-Setup". The default value is None. :vartype component_name: str :ivar setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :vartype setting_name: str or ~azure.mgmt.compute.v2022_03_01.models.SettingNames :ivar content: Specifies the XML formatted content that is added to the unattend.xml file for @@ -85,7 +87,7 @@ def __init__( *, pass_name: Optional[str] = None, component_name: Optional[str] = None, - setting_name: Optional[Union[str, "SettingNames"]] = None, + setting_name: Optional[Union[str, "_models.SettingNames"]] = None, content: Optional[str] = None, **kwargs ): @@ -98,7 +100,7 @@ def __init__( "Microsoft-Windows-Shell-Setup". The default value is None. :paramtype component_name: str :keyword setting_name: Specifies the name of the setting to which the content applies. Possible - values are: FirstLogonCommands and AutoLogon. Possible values include: "AutoLogon", + values are: FirstLogonCommands and AutoLogon. Known values are: "AutoLogon", "FirstLogonCommands". :paramtype setting_name: str or ~azure.mgmt.compute.v2022_03_01.models.SettingNames :keyword content: Specifies the XML formatted content that is added to the unattend.xml file @@ -166,8 +168,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -248,7 +250,7 @@ class ApplicationProfile(msrest.serialization.Model): def __init__( self, *, - gallery_applications: Optional[List["VMGalleryApplication"]] = None, + gallery_applications: Optional[List["_models.VMGalleryApplication"]] = None, **kwargs ): """ @@ -362,8 +364,8 @@ class AutomaticRepairsPolicy(msrest.serialization.Model): maximum allowed grace period is 90 minutes (PT90M). :vartype grace_period: str :ivar repair_action: Type of repair action (replace, restart, reimage) that will be used for - repairing unhealthy virtual machines in the scale set. Default value is replace. Possible - values include: "Replace", "Restart", "Reimage". + repairing unhealthy virtual machines in the scale set. Default value is replace. Known values + are: "Replace", "Restart", "Reimage". :vartype repair_action: str or ~azure.mgmt.compute.v2022_03_01.models.RepairAction """ @@ -378,7 +380,7 @@ def __init__( *, enabled: Optional[bool] = None, grace_period: Optional[str] = None, - repair_action: Optional[Union[str, "RepairAction"]] = None, + repair_action: Optional[Union[str, "_models.RepairAction"]] = None, **kwargs ): """ @@ -392,8 +394,8 @@ def __init__( value. The maximum allowed grace period is 90 minutes (PT90M). :paramtype grace_period: str :keyword repair_action: Type of repair action (replace, restart, reimage) that will be used for - repairing unhealthy virtual machines in the scale set. Default value is replace. Possible - values include: "Replace", "Restart", "Reimage". + repairing unhealthy virtual machines in the scale set. Default value is replace. Known values + are: "Replace", "Restart", "Reimage". :paramtype repair_action: str or ~azure.mgmt.compute.v2022_03_01.models.RepairAction """ super(AutomaticRepairsPolicy, self).__init__(**kwargs) @@ -520,11 +522,11 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -582,7 +584,7 @@ class AvailabilitySetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["AvailabilitySet"], + value: List["_models.AvailabilitySet"], next_link: Optional[str] = None, **kwargs ): @@ -664,11 +666,11 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, platform_update_domain_count: Optional[int] = None, platform_fault_domain_count: Optional[int] = None, - virtual_machines: Optional[List["SubResource"]] = None, - proximity_placement_group: Optional["SubResource"] = None, + virtual_machines: Optional[List["_models.SubResource"]] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -704,8 +706,8 @@ class AvailablePatchSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2022_03_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -973,7 +975,7 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, **kwargs @@ -1144,7 +1146,7 @@ class CapacityReservationGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["CapacityReservationGroup"], + value: List["_models.CapacityReservationGroup"], next_link: Optional[str] = None, **kwargs ): @@ -1228,8 +1230,8 @@ class CapacityReservationInstanceView(msrest.serialization.Model): def __init__( self, *, - utilization_info: Optional["CapacityReservationUtilization"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + utilization_info: Optional["_models.CapacityReservationUtilization"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1271,8 +1273,8 @@ class CapacityReservationInstanceViewWithName(CapacityReservationInstanceView): def __init__( self, *, - utilization_info: Optional["CapacityReservationUtilization"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + utilization_info: Optional["_models.CapacityReservationUtilization"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -1310,7 +1312,7 @@ class CapacityReservationListResult(msrest.serialization.Model): def __init__( self, *, - value: List["CapacityReservation"], + value: List["_models.CapacityReservation"], next_link: Optional[str] = None, **kwargs ): @@ -1343,7 +1345,7 @@ class CapacityReservationProfile(msrest.serialization.Model): def __init__( self, *, - capacity_reservation_group: Optional["SubResource"] = None, + capacity_reservation_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -1412,7 +1414,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, **kwargs ): """ @@ -1565,8 +1567,7 @@ class DataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1577,7 +1578,7 @@ class DataDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1604,14 +1605,14 @@ class DataDisk(msrest.serialization.Model): force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. :code:`
`:code:`
` This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data - disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Possible - values include: "ForceDetach". + disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Known values + are: "ForceDetach". :vartype detach_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskDetachOptionTypes :ivar delete_option: Specifies whether data disk should be deleted or detached upon VM deletion.:code:`
`:code:`
` Possible values: :code:`
`:code:`
` **Delete** If this value is used, the data disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the data disk is retained after VM is deleted.:code:`
`:code:`
` - The default value is set to **detach**. Possible values include: "Delete", "Detach". + The default value is set to **detach**. Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskDeleteOptionTypes """ @@ -1643,17 +1644,17 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, to_be_detached: Optional[bool] = None, - detach_option: Optional[Union[str, "DiskDetachOptionTypes"]] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + detach_option: Optional[Union[str, "_models.DiskDetachOptionTypes"]] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ @@ -1672,8 +1673,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -1684,7 +1684,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -1703,14 +1703,14 @@ def __init__( force-detach as a last resort option to detach the disk forcibly from the VM. All writes might not have been flushed when using this detach behavior. :code:`
`:code:`
` This feature is still in preview mode and is not supported for VirtualMachineScaleSet. To force-detach a data - disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Possible - values include: "ForceDetach". + disk update toBeDetached to 'true' along with setting detachOption: 'ForceDetach'. Known values + are: "ForceDetach". :paramtype detach_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskDetachOptionTypes :keyword delete_option: Specifies whether data disk should be deleted or detached upon VM deletion.:code:`
`:code:`
` Possible values: :code:`
`:code:`
` **Delete** If this value is used, the data disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the data disk is retained after VM is deleted.:code:`
`:code:`
` - The default value is set to **detach**. Possible values include: "Delete", "Detach". + The default value is set to **detach**. Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskDeleteOptionTypes """ super(DataDisk, self).__init__(**kwargs) @@ -1792,7 +1792,7 @@ class DedicatedHost(Resource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2022_03_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -1842,11 +1842,11 @@ def __init__( self, *, location: str, - sku: "Sku", + sku: "_models.Sku", tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -1867,7 +1867,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2022_03_01.models.DedicatedHostLicenseTypes """ @@ -1934,7 +1934,7 @@ class DedicatedHostAvailableCapacity(msrest.serialization.Model): def __init__( self, *, - allocatable_v_ms: Optional[List["DedicatedHostAllocatableVM"]] = None, + allocatable_v_ms: Optional[List["_models.DedicatedHostAllocatableVM"]] = None, **kwargs ): """ @@ -2019,7 +2019,7 @@ def __init__( zones: Optional[List[str]] = None, platform_fault_domain_count: Optional[int] = None, support_automatic_placement: Optional[bool] = None, - additional_capabilities: Optional["DedicatedHostGroupPropertiesAdditionalCapabilities"] = None, + additional_capabilities: Optional["_models.DedicatedHostGroupPropertiesAdditionalCapabilities"] = None, **kwargs ): """ @@ -2067,7 +2067,7 @@ class DedicatedHostGroupInstanceView(msrest.serialization.Model): def __init__( self, *, - hosts: Optional[List["DedicatedHostInstanceViewWithName"]] = None, + hosts: Optional[List["_models.DedicatedHostInstanceViewWithName"]] = None, **kwargs ): """ @@ -2103,7 +2103,7 @@ class DedicatedHostGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHostGroup"], + value: List["_models.DedicatedHostGroup"], next_link: Optional[str] = None, **kwargs ): @@ -2211,7 +2211,7 @@ def __init__( zones: Optional[List[str]] = None, platform_fault_domain_count: Optional[int] = None, support_automatic_placement: Optional[bool] = None, - additional_capabilities: Optional["DedicatedHostGroupPropertiesAdditionalCapabilities"] = None, + additional_capabilities: Optional["_models.DedicatedHostGroupPropertiesAdditionalCapabilities"] = None, **kwargs ): """ @@ -2271,8 +2271,8 @@ class DedicatedHostInstanceView(msrest.serialization.Model): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2320,8 +2320,8 @@ class DedicatedHostInstanceViewWithName(DedicatedHostInstanceView): def __init__( self, *, - available_capacity: Optional["DedicatedHostAvailableCapacity"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + available_capacity: Optional["_models.DedicatedHostAvailableCapacity"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2359,7 +2359,7 @@ class DedicatedHostListResult(msrest.serialization.Model): def __init__( self, *, - value: List["DedicatedHost"], + value: List["_models.DedicatedHost"], next_link: Optional[str] = None, **kwargs ): @@ -2396,7 +2396,7 @@ class DedicatedHostUpdate(UpdateResource): deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :vartype license_type: str or ~azure.mgmt.compute.v2022_03_01.models.DedicatedHostLicenseTypes :ivar provisioning_time: The date when the host was first provisioned. :vartype provisioning_time: ~datetime.datetime @@ -2438,7 +2438,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, platform_fault_domain: Optional[int] = None, auto_replace_on_failure: Optional[bool] = None, - license_type: Optional[Union[str, "DedicatedHostLicenseTypes"]] = None, + license_type: Optional[Union[str, "_models.DedicatedHostLicenseTypes"]] = None, **kwargs ): """ @@ -2454,7 +2454,7 @@ def __init__( deployed on the dedicated host. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **Windows_Server_Hybrid** :code:`
`:code:`
` **Windows_Server_Perpetual** :code:`
`:code:`
` Default: - **None**. Possible values include: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". + **None**. Known values are: "None", "Windows_Server_Hybrid", "Windows_Server_Perpetual". :paramtype license_type: str or ~azure.mgmt.compute.v2022_03_01.models.DedicatedHostLicenseTypes """ @@ -2489,7 +2489,7 @@ class DiagnosticsProfile(msrest.serialization.Model): def __init__( self, *, - boot_diagnostics: Optional["BootDiagnostics"] = None, + boot_diagnostics: Optional["_models.BootDiagnostics"] = None, **kwargs ): """ @@ -2508,8 +2508,8 @@ def __init__( class DiffDiskSettings(msrest.serialization.Model): """Describes the parameters of ephemeral disk settings that can be specified for operating system disk. :code:`
`:code:`
` NOTE: The ephemeral disk settings can only be specified for managed disk. - :ivar option: Specifies the ephemeral disk settings for operating system disk. Possible values - include: "Local". + :ivar option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :vartype option: str or ~azure.mgmt.compute.v2022_03_01.models.DiffDiskOptions :ivar placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -2518,7 +2518,7 @@ class DiffDiskSettings(msrest.serialization.Model): Refer to VM size documentation for Windows VM at https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Possible values include: "CacheDisk", "ResourceDisk". + cache disk. Known values are: "CacheDisk", "ResourceDisk". :vartype placement: str or ~azure.mgmt.compute.v2022_03_01.models.DiffDiskPlacement """ @@ -2530,13 +2530,13 @@ class DiffDiskSettings(msrest.serialization.Model): def __init__( self, *, - option: Optional[Union[str, "DiffDiskOptions"]] = None, - placement: Optional[Union[str, "DiffDiskPlacement"]] = None, + option: Optional[Union[str, "_models.DiffDiskOptions"]] = None, + placement: Optional[Union[str, "_models.DiffDiskPlacement"]] = None, **kwargs ): """ - :keyword option: Specifies the ephemeral disk settings for operating system disk. Possible - values include: "Local". + :keyword option: Specifies the ephemeral disk settings for operating system disk. Known values + are: "Local". :paramtype option: str or ~azure.mgmt.compute.v2022_03_01.models.DiffDiskOptions :keyword placement: Specifies the ephemeral disk placement for operating system disk.:code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **CacheDisk** @@ -2545,7 +2545,7 @@ def __init__( Refer to VM size documentation for Windows VM at https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM sizes exposes a - cache disk. Possible values include: "CacheDisk", "ResourceDisk". + cache disk. Known values are: "CacheDisk", "ResourceDisk". :paramtype placement: str or ~azure.mgmt.compute.v2022_03_01.models.DiffDiskPlacement """ super(DiffDiskSettings, self).__init__(**kwargs) @@ -2556,8 +2556,7 @@ def __init__( class DisallowedConfiguration(msrest.serialization.Model): """Specifies the disallowed configuration for a virtual machine image. - :ivar vm_disk_type: VM disk types which are disallowed. Possible values include: "None", - "Unmanaged". + :ivar vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :vartype vm_disk_type: str or ~azure.mgmt.compute.v2022_03_01.models.VmDiskTypes """ @@ -2568,11 +2567,11 @@ class DisallowedConfiguration(msrest.serialization.Model): def __init__( self, *, - vm_disk_type: Optional[Union[str, "VmDiskTypes"]] = None, + vm_disk_type: Optional[Union[str, "_models.VmDiskTypes"]] = None, **kwargs ): """ - :keyword vm_disk_type: VM disk types which are disallowed. Possible values include: "None", + :keyword vm_disk_type: VM disk types which are disallowed. Known values are: "None", "Unmanaged". :paramtype vm_disk_type: str or ~azure.mgmt.compute.v2022_03_01.models.VmDiskTypes """ @@ -2650,8 +2649,8 @@ class DiskEncryptionSettings(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultSecretReference"] = None, - key_encryption_key: Optional["KeyVaultKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultKeyReference"] = None, enabled: Optional[bool] = None, **kwargs ): @@ -2693,8 +2692,8 @@ def __init__( self, *, name: Optional[str] = None, - encryption_settings: Optional[List["DiskEncryptionSettings"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + encryption_settings: Optional[List["_models.DiskEncryptionSettings"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -2732,7 +2731,7 @@ def __init__( self, *, id: Optional[str] = None, - replication_status: Optional["DiskRestorePointReplicationStatus"] = None, + replication_status: Optional["_models.DiskRestorePointReplicationStatus"] = None, **kwargs ): """ @@ -2764,7 +2763,7 @@ class DiskRestorePointReplicationStatus(msrest.serialization.Model): def __init__( self, *, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, completion_percent: Optional[int] = None, **kwargs ): @@ -2784,7 +2783,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.compute.v2022_03_01.models.ExtendedLocationTypes """ @@ -2797,13 +2796,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.compute.v2022_03_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -2825,7 +2824,7 @@ class HardwareProfile(msrest.serialization.Model): `_. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The - available VM sizes depend on region and availability set. Possible values include: "Basic_A0", + available VM sizes depend on region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", @@ -2877,8 +2876,8 @@ class HardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size: Optional[Union[str, "VirtualMachineSizeTypes"]] = None, - vm_size_properties: Optional["VMSizeProperties"] = None, + vm_size: Optional[Union[str, "_models.VirtualMachineSizeTypes"]] = None, + vm_size_properties: Optional["_models.VMSizeProperties"] = None, **kwargs ): """ @@ -2893,7 +2892,7 @@ def __init__( `_. For more information about virtual machine sizes, see `Sizes for virtual machines `_. :code:`
`:code:`
` The - available VM sizes depend on region and availability set. Possible values include: "Basic_A0", + available VM sizes depend on region and availability set. Known values are: "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_A0", "Standard_A1", "Standard_A2", "Standard_A3", "Standard_A4", "Standard_A5", "Standard_A6", "Standard_A7", "Standard_A8", "Standard_A9", "Standard_A10", "Standard_A11", "Standard_A1_v2", "Standard_A2_v2", @@ -2969,8 +2968,8 @@ class Image(Resource): :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Possible - values include: "V1", "V2". + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_01.models.HyperVGenerationTypes """ @@ -3001,10 +3000,10 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -3022,7 +3021,7 @@ def __init__( from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the user to specify the property if we cannot deduce it from the source managed - resource. Possible values include: "V1", "V2". + resource. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_01.models.HyperVGenerationTypes """ @@ -3046,16 +3045,15 @@ class ImageDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_03_01.models.StorageAccountTypes @@ -3078,13 +3076,13 @@ class ImageDisk(msrest.serialization.Model): def __init__( self, *, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3097,16 +3095,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2022_03_01.models.StorageAccountTypes @@ -3139,16 +3136,15 @@ class ImageDataDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_03_01.models.StorageAccountTypes @@ -3181,13 +3177,13 @@ def __init__( self, *, lun: int, - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3200,16 +3196,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2022_03_01.models.StorageAccountTypes @@ -3250,7 +3245,7 @@ class ImageListResult(msrest.serialization.Model): def __init__( self, *, - value: List["Image"], + value: List["_models.Image"], next_link: Optional[str] = None, **kwargs ): @@ -3280,16 +3275,15 @@ class ImageOSDisk(ImageDisk): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :ivar disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :vartype disk_size_gb: int :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_03_01.models.StorageAccountTypes @@ -3299,10 +3293,10 @@ class ImageOSDisk(ImageDisk): ~azure.mgmt.compute.v2022_03_01.models.DiskEncryptionSetParameters :ivar os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemTypes - :ivar os_state: Required. The OS State. Possible values include: "Generalized", "Specialized". + :ivar os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :vartype os_state: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemStateTypes """ @@ -3326,15 +3320,15 @@ class ImageOSDisk(ImageDisk): def __init__( self, *, - os_type: Union[str, "OperatingSystemTypes"], - os_state: Union[str, "OperatingSystemStateTypes"], - snapshot: Optional["SubResource"] = None, - managed_disk: Optional["SubResource"] = None, + os_type: Union[str, "_models.OperatingSystemTypes"], + os_state: Union[str, "_models.OperatingSystemStateTypes"], + snapshot: Optional["_models.SubResource"] = None, + managed_disk: Optional["_models.SubResource"] = None, blob_uri: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ @@ -3347,16 +3341,15 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :keyword disk_size_gb: Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. :code:`
`:code:`
` This value cannot be larger than 1023 GB. :paramtype disk_size_gb: int :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2022_03_01.models.StorageAccountTypes @@ -3366,11 +3359,10 @@ def __init__( ~azure.mgmt.compute.v2022_03_01.models.DiskEncryptionSetParameters :keyword os_type: Required. This property allows you to specify the type of the OS that is included in the disk if creating a VM from a custom image. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemTypes - :keyword os_state: Required. The OS State. Possible values include: "Generalized", - "Specialized". + :keyword os_state: Required. The OS State. Known values are: "Generalized", "Specialized". :paramtype os_state: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemStateTypes """ super(ImageOSDisk, self).__init__(snapshot=snapshot, managed_disk=managed_disk, blob_uri=blob_uri, caching=caching, disk_size_gb=disk_size_gb, storage_account_type=storage_account_type, disk_encryption_set=disk_encryption_set, **kwargs) @@ -3505,8 +3497,8 @@ class ImageStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["ImageOSDisk"] = None, - data_disks: Optional[List["ImageDataDisk"]] = None, + os_disk: Optional["_models.ImageOSDisk"] = None, + data_disks: Optional[List["_models.ImageDataDisk"]] = None, zone_resilient: Optional[bool] = None, **kwargs ): @@ -3547,8 +3539,8 @@ class ImageUpdate(UpdateResource): :ivar hyper_v_generation: Specifies the HyperVGenerationType of the VirtualMachine created from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the - user to specify the property if we cannot deduce it from the source managed resource. Possible - values include: "V1", "V2". + user to specify the property if we cannot deduce it from the source managed resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_01.models.HyperVGenerationTypes """ @@ -3569,9 +3561,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source_virtual_machine: Optional["SubResource"] = None, - storage_profile: Optional["ImageStorageProfile"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, + source_virtual_machine: Optional["_models.SubResource"] = None, + storage_profile: Optional["_models.ImageStorageProfile"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, **kwargs ): """ @@ -3585,7 +3577,7 @@ def __init__( from the image. From API Version 2019-03-01 if the image source is a blob, then we need the user to specify the value, if the source is managed resource like disk or snapshot, we may require the user to specify the property if we cannot deduce it from the source managed - resource. Possible values include: "V1", "V2". + resource. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_01.models.HyperVGenerationTypes """ @@ -3633,7 +3625,7 @@ class InstanceViewStatus(msrest.serialization.Model): :ivar code: The status code. :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". + :ivar level: The level code. Known values are: "Info", "Warning", "Error". :vartype level: str or ~azure.mgmt.compute.v2022_03_01.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -3655,7 +3647,7 @@ def __init__( self, *, code: Optional[str] = None, - level: Optional[Union[str, "StatusLevelTypes"]] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, display_status: Optional[str] = None, message: Optional[str] = None, time: Optional[datetime.datetime] = None, @@ -3664,7 +3656,7 @@ def __init__( """ :keyword code: The status code. :paramtype code: str - :keyword level: The level code. Possible values include: "Info", "Warning", "Error". + :keyword level: The level code. Known values are: "Info", "Warning", "Error". :paramtype level: str or ~azure.mgmt.compute.v2022_03_01.models.StatusLevelTypes :keyword display_status: The short localizable label for the status. :paramtype display_status: str @@ -3706,7 +3698,7 @@ def __init__( self, *, key_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -3745,7 +3737,7 @@ def __init__( self, *, secret_url: str, - source_vault: "SubResource", + source_vault: "_models.SubResource", **kwargs ): """ @@ -3766,8 +3758,8 @@ class LastPatchInstallationSummary(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2022_03_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -3874,9 +3866,9 @@ def __init__( self, *, disable_password_authentication: Optional[bool] = None, - ssh: Optional["SshConfiguration"] = None, + ssh: Optional["_models.SshConfiguration"] = None, provision_vm_agent: Optional[bool] = None, - patch_settings: Optional["LinuxPatchSettings"] = None, + patch_settings: Optional["_models.LinuxPatchSettings"] = None, **kwargs ): """ @@ -3929,7 +3921,7 @@ class LinuxParameters(msrest.serialization.Model): def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "VMGuestPatchClassificationLinux"]]] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationLinux"]]] = None, package_name_masks_to_include: Optional[List[str]] = None, package_name_masks_to_exclude: Optional[List[str]] = None, maintenance_run_id: Optional[str] = None, @@ -3965,15 +3957,15 @@ class LinuxPatchSettings(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. Possible values include: "ImageDefault", + The property provisionVMAgent must be true. Known values are: "ImageDefault", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2022_03_01.models.LinuxVMGuestPatchMode :ivar assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :vartype assessment_mode: str or ~azure.mgmt.compute.v2022_03_01.models.LinuxPatchAssessmentMode :ivar automatic_by_platform_settings: Specifies additional settings for patch mode @@ -3991,9 +3983,9 @@ class LinuxPatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "LinuxVMGuestPatchMode"]] = None, - assessment_mode: Optional[Union[str, "LinuxPatchAssessmentMode"]] = None, - automatic_by_platform_settings: Optional["LinuxVMGuestPatchAutomaticByPlatformSettings"] = None, + patch_mode: Optional[Union[str, "_models.LinuxVMGuestPatchMode"]] = None, + assessment_mode: Optional[Union[str, "_models.LinuxPatchAssessmentMode"]] = None, + automatic_by_platform_settings: Optional["_models.LinuxVMGuestPatchAutomaticByPlatformSettings"] = None, **kwargs ): """ @@ -4002,15 +3994,15 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - The virtual machine's default patching configuration is used. :code:`
`:code:`
` **AutomaticByPlatform** - The virtual machine will be automatically updated by the platform. - The property provisionVMAgent must be true. Possible values include: "ImageDefault", + The property provisionVMAgent must be true. Known values are: "ImageDefault", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2022_03_01.models.LinuxVMGuestPatchMode :keyword assessment_mode: Specifies the mode of VM Guest Patch Assessment for the IaaS virtual machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine. :code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :paramtype assessment_mode: str or ~azure.mgmt.compute.v2022_03_01.models.LinuxPatchAssessmentMode :keyword automatic_by_platform_settings: Specifies additional settings for patch mode @@ -4028,7 +4020,7 @@ class LinuxVMGuestPatchAutomaticByPlatformSettings(msrest.serialization.Model): """Specifies additional settings to be applied when patch mode AutomaticByPlatform is selected in Linux patch settings. :ivar reboot_setting: Specifies the reboot setting for all AutomaticByPlatform patch - installation operations. Possible values include: "Unknown", "IfRequired", "Never", "Always". + installation operations. Known values are: "Unknown", "IfRequired", "Never", "Always". :vartype reboot_setting: str or ~azure.mgmt.compute.v2022_03_01.models.LinuxVMGuestPatchAutomaticByPlatformRebootSetting """ @@ -4040,12 +4032,12 @@ class LinuxVMGuestPatchAutomaticByPlatformSettings(msrest.serialization.Model): def __init__( self, *, - reboot_setting: Optional[Union[str, "LinuxVMGuestPatchAutomaticByPlatformRebootSetting"]] = None, + reboot_setting: Optional[Union[str, "_models.LinuxVMGuestPatchAutomaticByPlatformRebootSetting"]] = None, **kwargs ): """ :keyword reboot_setting: Specifies the reboot setting for all AutomaticByPlatform patch - installation operations. Possible values include: "Unknown", "IfRequired", "Never", "Always". + installation operations. Known values are: "Unknown", "IfRequired", "Never", "Always". :paramtype reboot_setting: str or ~azure.mgmt.compute.v2022_03_01.models.LinuxVMGuestPatchAutomaticByPlatformRebootSetting """ @@ -4077,7 +4069,7 @@ class ListUsagesResult(msrest.serialization.Model): def __init__( self, *, - value: List["Usage"], + value: List["_models.Usage"], next_link: Optional[str] = None, **kwargs ): @@ -4245,8 +4237,8 @@ class MaintenanceRedeployStatus(msrest.serialization.Model): :vartype maintenance_window_start_time: ~datetime.datetime :ivar maintenance_window_end_time: End Time for the Maintenance Window. :vartype maintenance_window_end_time: ~datetime.datetime - :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Possible values - include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :ivar last_operation_result_code: The Last Maintenance Operation Result Code. Known values are: + "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :vartype last_operation_result_code: str or ~azure.mgmt.compute.v2022_03_01.models.MaintenanceOperationResultCodeTypes :ivar last_operation_message: Message returned for the last Maintenance Operation. @@ -4271,7 +4263,7 @@ def __init__( pre_maintenance_window_end_time: Optional[datetime.datetime] = None, maintenance_window_start_time: Optional[datetime.datetime] = None, maintenance_window_end_time: Optional[datetime.datetime] = None, - last_operation_result_code: Optional[Union[str, "MaintenanceOperationResultCodeTypes"]] = None, + last_operation_result_code: Optional[Union[str, "_models.MaintenanceOperationResultCodeTypes"]] = None, last_operation_message: Optional[str] = None, **kwargs ): @@ -4287,8 +4279,8 @@ def __init__( :paramtype maintenance_window_start_time: ~datetime.datetime :keyword maintenance_window_end_time: End Time for the Maintenance Window. :paramtype maintenance_window_end_time: ~datetime.datetime - :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Possible - values include: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". + :keyword last_operation_result_code: The Last Maintenance Operation Result Code. Known values + are: "None", "RetryLater", "MaintenanceAborted", "MaintenanceCompleted". :paramtype last_operation_result_code: str or ~azure.mgmt.compute.v2022_03_01.models.MaintenanceOperationResultCodeTypes :keyword last_operation_message: Message returned for the last Maintenance Operation. @@ -4310,8 +4302,8 @@ class ManagedDiskParameters(SubResource): :ivar id: Resource Id. :vartype id: str :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_03_01.models.StorageAccountTypes @@ -4334,17 +4326,17 @@ def __init__( self, *, id: Optional[str] = None, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, - security_profile: Optional["VMDiskSecurityProfile"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, + security_profile: Optional["_models.VMDiskSecurityProfile"] = None, **kwargs ): """ :keyword id: Resource Id. :paramtype id: str :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2022_03_01.models.StorageAccountTypes @@ -4370,7 +4362,7 @@ class NetworkInterfaceReference(SubResource): than 1 network interface. :vartype primary: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions """ @@ -4385,7 +4377,7 @@ def __init__( *, id: Optional[str] = None, primary: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -4395,7 +4387,7 @@ def __init__( than 1 network interface. :paramtype primary: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions """ super(NetworkInterfaceReference, self).__init__(id=id, **kwargs) @@ -4411,8 +4403,7 @@ class NetworkProfile(msrest.serialization.Model): :vartype network_interfaces: list[~azure.mgmt.compute.v2022_03_01.models.NetworkInterfaceReference] :ivar network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. Possible values include: - "2020-11-01". + networking resources in the Network Interface Configurations. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2022_03_01.models.NetworkApiVersion :ivar network_interface_configurations: Specifies the networking configurations that will be used to create the virtual machine networking resources. @@ -4429,9 +4420,9 @@ class NetworkProfile(msrest.serialization.Model): def __init__( self, *, - network_interfaces: Optional[List["NetworkInterfaceReference"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, - network_interface_configurations: Optional[List["VirtualMachineNetworkInterfaceConfiguration"]] = None, + network_interfaces: Optional[List["_models.NetworkInterfaceReference"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceConfiguration"]] = None, **kwargs ): """ @@ -4440,8 +4431,7 @@ def __init__( :paramtype network_interfaces: list[~azure.mgmt.compute.v2022_03_01.models.NetworkInterfaceReference] :keyword network_api_version: specifies the Microsoft.Network API version used when creating - networking resources in the Network Interface Configurations. Possible values include: - "2020-11-01". + networking resources in the Network Interface Configurations. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2022_03_01.models.NetworkApiVersion :keyword network_interface_configurations: Specifies the networking configurations that will be used to create the virtual machine networking resources. @@ -4459,11 +4449,10 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs", "DummyOrchestrationServiceName". + :ivar service_name: Required. The name of the service. Known values are: "AutomaticRepairs", + "DummyOrchestrationServiceName". :vartype service_name: str or ~azure.mgmt.compute.v2022_03_01.models.OrchestrationServiceNames - :ivar action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :ivar action: Required. The action to be performed. Known values are: "Resume", "Suspend". :vartype action: str or ~azure.mgmt.compute.v2022_03_01.models.OrchestrationServiceStateAction """ @@ -4480,17 +4469,16 @@ class OrchestrationServiceStateInput(msrest.serialization.Model): def __init__( self, *, - service_name: Union[str, "OrchestrationServiceNames"], - action: Union[str, "OrchestrationServiceStateAction"], + service_name: Union[str, "_models.OrchestrationServiceNames"], + action: Union[str, "_models.OrchestrationServiceStateAction"], **kwargs ): """ - :keyword service_name: Required. The name of the service. Possible values include: - "AutomaticRepairs", "DummyOrchestrationServiceName". + :keyword service_name: Required. The name of the service. Known values are: "AutomaticRepairs", + "DummyOrchestrationServiceName". :paramtype service_name: str or ~azure.mgmt.compute.v2022_03_01.models.OrchestrationServiceNames - :keyword action: Required. The action to be performed. Possible values include: "Resume", - "Suspend". + :keyword action: Required. The action to be performed. Known values are: "Resume", "Suspend". :paramtype action: str or ~azure.mgmt.compute.v2022_03_01.models.OrchestrationServiceStateAction """ @@ -4504,10 +4492,10 @@ class OrchestrationServiceSummary(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar service_name: The name of the service. Possible values include: "AutomaticRepairs", + :ivar service_name: The name of the service. Known values are: "AutomaticRepairs", "DummyOrchestrationServiceName". :vartype service_name: str or ~azure.mgmt.compute.v2022_03_01.models.OrchestrationServiceNames - :ivar service_state: The current state of the service. Possible values include: "NotRunning", + :ivar service_state: The current state of the service. Known values are: "NotRunning", "Running", "Suspended". :vartype service_state: str or ~azure.mgmt.compute.v2022_03_01.models.OrchestrationServiceState """ @@ -4540,8 +4528,8 @@ class OSDisk(msrest.serialization.Model): :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemTypes :ivar encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -4557,8 +4545,7 @@ class OSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -4572,7 +4559,7 @@ class OSDisk(msrest.serialization.Model): machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -4585,8 +4572,8 @@ class OSDisk(msrest.serialization.Model): used, the OS disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the os disk is retained after VM is deleted. :code:`
`:code:`
` The default value is set to **detach**. For an ephemeral OS Disk, the default value is set to - **Delete**. User cannot change the delete option for ephemeral OS Disk. Possible values - include: "Delete", "Detach". + **Delete**. User cannot change the delete option for ephemeral OS Disk. Known values are: + "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskDeleteOptionTypes """ @@ -4612,25 +4599,25 @@ class OSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + create_option: Union[str, "_models.DiskCreateOptionTypes"], + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - vhd: Optional["VirtualHardDisk"] = None, - image: Optional["VirtualHardDisk"] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + vhd: Optional["_models.VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemTypes :keyword encryption_settings: Specifies the encryption settings for the OS Disk. :code:`
`:code:`
` Minimum api-version: 2015-06-15. @@ -4646,8 +4633,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None** for Standard - storage. **ReadOnly** for Premium storage. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. **ReadOnly** for Premium storage. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -4661,7 +4647,7 @@ def __init__( machine.:code:`
`:code:`
` **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the - plan element previously described. Possible values include: "FromImage", "Empty", "Attach". + plan element previously described. Known values are: "FromImage", "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -4674,8 +4660,8 @@ def __init__( value is used, the OS disk is deleted when VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the os disk is retained after VM is deleted. :code:`
`:code:`
` The default value is set to **detach**. For an ephemeral OS Disk, the default value is set to - **Delete**. User cannot change the delete option for ephemeral OS Disk. Possible values - include: "Delete", "Detach". + **Delete**. User cannot change the delete option for ephemeral OS Disk. Known values are: + "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskDeleteOptionTypes """ super(OSDisk, self).__init__(**kwargs) @@ -4698,8 +4684,8 @@ class OSDiskImage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :ivar operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :vartype operating_system: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemTypes """ @@ -4714,12 +4700,12 @@ class OSDiskImage(msrest.serialization.Model): def __init__( self, *, - operating_system: Union[str, "OperatingSystemTypes"], + operating_system: Union[str, "_models.OperatingSystemTypes"], **kwargs ): """ - :keyword operating_system: Required. The operating system of the osDiskImage. Possible values - include: "Windows", "Linux". + :keyword operating_system: Required. The operating system of the osDiskImage. Known values are: + "Windows", "Linux". :paramtype operating_system: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemTypes """ super(OSDiskImage, self).__init__(**kwargs) @@ -4815,9 +4801,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, require_guest_provision_signal: Optional[bool] = None, **kwargs @@ -4919,8 +4905,7 @@ class PatchInstallationDetail(msrest.serialization.Model): :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] :ivar installation_state: The state of the patch after the installation operation completed. - Possible values include: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", - "Pending". + Known values are: "Unknown", "Installed", "Failed", "Excluded", "NotSelected", "Pending". :vartype installation_state: str or ~azure.mgmt.compute.v2022_03_01.models.PatchInstallationState """ @@ -4970,8 +4955,8 @@ class PatchSettings(msrest.serialization.Model): **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :vartype patch_mode: str or ~azure.mgmt.compute.v2022_03_01.models.WindowsVMGuestPatchMode :ivar enable_hotpatching: Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must @@ -4981,8 +4966,8 @@ class PatchSettings(msrest.serialization.Model): machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :vartype assessment_mode: str or ~azure.mgmt.compute.v2022_03_01.models.WindowsPatchAssessmentMode :ivar automatic_by_platform_settings: Specifies additional settings for patch mode @@ -5001,10 +4986,10 @@ class PatchSettings(msrest.serialization.Model): def __init__( self, *, - patch_mode: Optional[Union[str, "WindowsVMGuestPatchMode"]] = None, + patch_mode: Optional[Union[str, "_models.WindowsVMGuestPatchMode"]] = None, enable_hotpatching: Optional[bool] = None, - assessment_mode: Optional[Union[str, "WindowsPatchAssessmentMode"]] = None, - automatic_by_platform_settings: Optional["WindowsVMGuestPatchAutomaticByPlatformSettings"] = None, + assessment_mode: Optional[Union[str, "_models.WindowsPatchAssessmentMode"]] = None, + automatic_by_platform_settings: Optional["_models.WindowsVMGuestPatchAutomaticByPlatformSettings"] = None, **kwargs ): """ @@ -5017,8 +5002,8 @@ def __init__( **AutomaticByOS** - The virtual machine will automatically be updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates must be true. :code:`
`:code:`
` **AutomaticByPlatform** - the virtual machine will automatically updated by the platform. The - properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. - Possible values include: "Manual", "AutomaticByOS", "AutomaticByPlatform". + properties provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. Known + values are: "Manual", "AutomaticByOS", "AutomaticByPlatform". :paramtype patch_mode: str or ~azure.mgmt.compute.v2022_03_01.models.WindowsVMGuestPatchMode :keyword enable_hotpatching: Enables customers to patch their Azure VMs without requiring a reboot. For enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' must @@ -5028,8 +5013,8 @@ def __init__( machine.:code:`
`:code:`
` Possible values are::code:`
`:code:`
` **ImageDefault** - You control the timing of patch assessments on a virtual machine.:code:`
`:code:`
` **AutomaticByPlatform** - The platform will trigger periodic patch - assessments. The property provisionVMAgent must be true. Possible values include: - "ImageDefault", "AutomaticByPlatform". + assessments. The property provisionVMAgent must be true. Known values are: "ImageDefault", + "AutomaticByPlatform". :paramtype assessment_mode: str or ~azure.mgmt.compute.v2022_03_01.models.WindowsPatchAssessmentMode :keyword automatic_by_platform_settings: Specifies additional settings for patch mode @@ -5115,7 +5100,7 @@ class ProximityPlacementGroup(Resource): :ivar proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :vartype proximity_placement_group_type: str or ~azure.mgmt.compute.v2022_03_01.models.ProximityPlacementGroupType :ivar virtual_machines: A list of references to all virtual machines in the proximity placement @@ -5167,9 +5152,9 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, - proximity_placement_group_type: Optional[Union[str, "ProximityPlacementGroupType"]] = None, - colocation_status: Optional["InstanceViewStatus"] = None, - intent: Optional["ProximityPlacementGroupPropertiesIntent"] = None, + proximity_placement_group_type: Optional[Union[str, "_models.ProximityPlacementGroupType"]] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, + intent: Optional["_models.ProximityPlacementGroupPropertiesIntent"] = None, **kwargs ): """ @@ -5183,7 +5168,7 @@ def __init__( :keyword proximity_placement_group_type: Specifies the type of the proximity placement group. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Standard** : Co-locate resources within an Azure region or Availability Zone. :code:`
`:code:`
` **Ultra** : For - future use. Possible values include: "Standard", "Ultra". + future use. Known values are: "Standard", "Ultra". :paramtype proximity_placement_group_type: str or ~azure.mgmt.compute.v2022_03_01.models.ProximityPlacementGroupType :keyword colocation_status: Describes colocation status of the Proximity Placement Group. @@ -5225,7 +5210,7 @@ class ProximityPlacementGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["ProximityPlacementGroup"], + value: List["_models.ProximityPlacementGroup"], next_link: Optional[str] = None, **kwargs ): @@ -5331,9 +5316,9 @@ def __init__( class PublicIPAddressSku(msrest.serialization.Model): """Describes the public IP Sku. It can only be set with OrchestrationMode as Flexible. - :ivar name: Specify public IP sku name. Possible values include: "Basic", "Standard". + :ivar name: Specify public IP sku name. Known values are: "Basic", "Standard". :vartype name: str or ~azure.mgmt.compute.v2022_03_01.models.PublicIPAddressSkuName - :ivar tier: Specify public IP sku tier. Possible values include: "Regional", "Global". + :ivar tier: Specify public IP sku tier. Known values are: "Regional", "Global". :vartype tier: str or ~azure.mgmt.compute.v2022_03_01.models.PublicIPAddressSkuTier """ @@ -5345,14 +5330,14 @@ class PublicIPAddressSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "PublicIPAddressSkuName"]] = None, - tier: Optional[Union[str, "PublicIPAddressSkuTier"]] = None, + name: Optional[Union[str, "_models.PublicIPAddressSkuName"]] = None, + tier: Optional[Union[str, "_models.PublicIPAddressSkuTier"]] = None, **kwargs ): """ - :keyword name: Specify public IP sku name. Possible values include: "Basic", "Standard". + :keyword name: Specify public IP sku name. Known values are: "Basic", "Standard". :paramtype name: str or ~azure.mgmt.compute.v2022_03_01.models.PublicIPAddressSkuName - :keyword tier: Specify public IP sku tier. Possible values include: "Regional", "Global". + :keyword tier: Specify public IP sku tier. Known values are: "Regional", "Global". :paramtype tier: str or ~azure.mgmt.compute.v2022_03_01.models.PublicIPAddressSkuTier """ super(PublicIPAddressSku, self).__init__(**kwargs) @@ -5465,7 +5450,7 @@ class RequestRateByIntervalInput(LogAnalyticsInputBase): :ivar group_by_user_agent: Group query result by User Agent. :vartype group_by_user_agent: bool :ivar interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :vartype interval_length: str or ~azure.mgmt.compute.v2022_03_01.models.IntervalInMins """ @@ -5494,7 +5479,7 @@ def __init__( blob_container_sas_uri: str, from_time: datetime.datetime, to_time: datetime.datetime, - interval_length: Union[str, "IntervalInMins"], + interval_length: Union[str, "_models.IntervalInMins"], group_by_throttle_policy: Optional[bool] = None, group_by_operation_name: Optional[bool] = None, group_by_resource_name: Optional[bool] = None, @@ -5521,7 +5506,7 @@ def __init__( :keyword group_by_user_agent: Group query result by User Agent. :paramtype group_by_user_agent: bool :keyword interval_length: Required. Interval value in minutes used to create LogAnalytics call - rate logs. Possible values include: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". + rate logs. Known values are: "ThreeMins", "FiveMins", "ThirtyMins", "SixtyMins". :paramtype interval_length: str or ~azure.mgmt.compute.v2022_03_01.models.IntervalInMins """ super(RequestRateByIntervalInput, self).__init__(blob_container_sas_uri=blob_container_sas_uri, from_time=from_time, to_time=to_time, group_by_throttle_policy=group_by_throttle_policy, group_by_operation_name=group_by_operation_name, group_by_resource_name=group_by_resource_name, group_by_client_application_id=group_by_client_application_id, group_by_user_agent=group_by_user_agent, **kwargs) @@ -5601,7 +5586,7 @@ class RestorePoint(ProxyResource): :vartype provisioning_state: str :ivar consistency_mode: ConsistencyMode of the RestorePoint. Can be specified in the input while creating a restore point. For now, only CrashConsistent is accepted as a valid input. - Please refer to https://aka.ms/RestorePoints for more details. Possible values include: + Please refer to https://aka.ms/RestorePoints for more details. Known values are: "CrashConsistent", "FileSystemConsistent", "ApplicationConsistent". :vartype consistency_mode: str or ~azure.mgmt.compute.v2022_03_01.models.ConsistencyModeTypes :ivar time_created: Gets the creation time of the restore point. @@ -5638,10 +5623,10 @@ class RestorePoint(ProxyResource): def __init__( self, *, - exclude_disks: Optional[List["ApiEntityReference"]] = None, - consistency_mode: Optional[Union[str, "ConsistencyModeTypes"]] = None, + exclude_disks: Optional[List["_models.ApiEntityReference"]] = None, + consistency_mode: Optional[Union[str, "_models.ConsistencyModeTypes"]] = None, time_created: Optional[datetime.datetime] = None, - source_restore_point: Optional["ApiEntityReference"] = None, + source_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs ): """ @@ -5650,7 +5635,7 @@ def __init__( :paramtype exclude_disks: list[~azure.mgmt.compute.v2022_03_01.models.ApiEntityReference] :keyword consistency_mode: ConsistencyMode of the RestorePoint. Can be specified in the input while creating a restore point. For now, only CrashConsistent is accepted as a valid input. - Please refer to https://aka.ms/RestorePoints for more details. Possible values include: + Please refer to https://aka.ms/RestorePoints for more details. Known values are: "CrashConsistent", "FileSystemConsistent", "ApplicationConsistent". :paramtype consistency_mode: str or ~azure.mgmt.compute.v2022_03_01.models.ConsistencyModeTypes :keyword time_created: Gets the creation time of the restore point. @@ -5725,7 +5710,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source: Optional["RestorePointCollectionSourceProperties"] = None, + source: Optional["_models.RestorePointCollectionSourceProperties"] = None, **kwargs ): """ @@ -5763,7 +5748,7 @@ class RestorePointCollectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["RestorePointCollection"]] = None, + value: Optional[List["_models.RestorePointCollection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -5851,7 +5836,7 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["RestorePointCollectionSourceProperties"] = None, + source: Optional["_models.RestorePointCollectionSourceProperties"] = None, **kwargs ): """ @@ -5887,8 +5872,8 @@ class RestorePointInstanceView(msrest.serialization.Model): def __init__( self, *, - disk_restore_points: Optional[List["DiskRestorePointInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + disk_restore_points: Optional[List["_models.DiskRestorePointInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -5939,13 +5924,13 @@ class RestorePointSourceMetadata(msrest.serialization.Model): def __init__( self, *, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["RestorePointSourceVMStorageProfile"] = None, - os_profile: Optional["OSProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.RestorePointSourceVMStorageProfile"] = None, + os_profile: Optional["_models.OSProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, license_type: Optional[str] = None, vm_id: Optional[str] = None, - security_profile: Optional["SecurityProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, location: Optional[str] = None, **kwargs ): @@ -5986,7 +5971,7 @@ class RestorePointSourceVMDataDisk(msrest.serialization.Model): :vartype lun: int :ivar name: Gets the disk name. :vartype name: str - :ivar caching: Gets the caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :ivar disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired size for existing OS and Data disks. @@ -6011,10 +5996,10 @@ def __init__( *, lun: Optional[int] = None, name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - disk_restore_point: Optional["ApiEntityReference"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + disk_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs ): """ @@ -6022,8 +6007,7 @@ def __init__( :paramtype lun: int :keyword name: Gets the disk name. :paramtype name: str - :keyword caching: Gets the caching type. Possible values include: "None", "ReadOnly", - "ReadWrite". + :keyword caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :keyword disk_size_gb: Gets the initial disk size in GB for blank data disks, and the new desired size for existing OS and Data disks. @@ -6045,13 +6029,13 @@ def __init__( class RestorePointSourceVMOSDisk(msrest.serialization.Model): """Describes an Operating System disk. - :ivar os_type: Gets the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: Gets the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemType :ivar encryption_settings: Gets the disk encryption settings. :vartype encryption_settings: ~azure.mgmt.compute.v2022_03_01.models.DiskEncryptionSettings :ivar name: Gets the disk name. :vartype name: str - :ivar caching: Gets the caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :ivar disk_size_gb: Gets the disk size in GB. :vartype disk_size_gb: int @@ -6074,24 +6058,23 @@ class RestorePointSourceVMOSDisk(msrest.serialization.Model): def __init__( self, *, - os_type: Optional[Union[str, "OperatingSystemType"]] = None, - encryption_settings: Optional["DiskEncryptionSettings"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemType"]] = None, + encryption_settings: Optional["_models.DiskEncryptionSettings"] = None, name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["ManagedDiskParameters"] = None, - disk_restore_point: Optional["ApiEntityReference"] = None, + managed_disk: Optional["_models.ManagedDiskParameters"] = None, + disk_restore_point: Optional["_models.ApiEntityReference"] = None, **kwargs ): """ - :keyword os_type: Gets the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: Gets the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemType :keyword encryption_settings: Gets the disk encryption settings. :paramtype encryption_settings: ~azure.mgmt.compute.v2022_03_01.models.DiskEncryptionSettings :keyword name: Gets the disk name. :paramtype name: str - :keyword caching: Gets the caching type. Possible values include: "None", "ReadOnly", - "ReadWrite". + :keyword caching: Gets the caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :keyword disk_size_gb: Gets the disk size in GB. :paramtype disk_size_gb: int @@ -6128,8 +6111,8 @@ class RestorePointSourceVMStorageProfile(msrest.serialization.Model): def __init__( self, *, - os_disk: Optional["RestorePointSourceVMOSDisk"] = None, - data_disks: Optional[List["RestorePointSourceVMDataDisk"]] = None, + os_disk: Optional["_models.RestorePointSourceVMOSDisk"] = None, + data_disks: Optional[List["_models.RestorePointSourceVMDataDisk"]] = None, **kwargs ): """ @@ -6360,13 +6343,13 @@ class RollingUpgradeRunningStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2022_03_01.models.RollingUpgradeStatusCode :ivar start_time: Start time of the upgrade. :vartype start_time: ~datetime.datetime - :ivar last_action: The last action performed on the rolling upgrade. Possible values include: - "Start", "Cancel". + :ivar last_action: The last action performed on the rolling upgrade. Known values are: "Start", + "Cancel". :vartype last_action: str or ~azure.mgmt.compute.v2022_03_01.models.RollingUpgradeActionType :ivar last_action_time: Last action time of the upgrade. :vartype last_action_time: ~datetime.datetime @@ -6479,8 +6462,7 @@ class RunCommandDocumentBase(msrest.serialization.Model): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -6509,7 +6491,7 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, **kwargs @@ -6519,8 +6501,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -6544,8 +6525,7 @@ class RunCommandDocument(RunCommandDocumentBase): :vartype schema: str :ivar id: Required. The VM run command id. :vartype id: str - :ivar os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :ivar os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemTypes :ivar label: Required. The VM run command label. :vartype label: str @@ -6581,11 +6561,11 @@ def __init__( *, schema: str, id: str, - os_type: Union[str, "OperatingSystemTypes"], + os_type: Union[str, "_models.OperatingSystemTypes"], label: str, description: str, script: List[str], - parameters: Optional[List["RunCommandParameterDefinition"]] = None, + parameters: Optional[List["_models.RunCommandParameterDefinition"]] = None, **kwargs ): """ @@ -6593,8 +6573,7 @@ def __init__( :paramtype schema: str :keyword id: Required. The VM run command id. :paramtype id: str - :keyword os_type: Required. The Operating System type. Possible values include: "Windows", - "Linux". + :keyword os_type: Required. The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemTypes :keyword label: Required. The VM run command label. :paramtype label: str @@ -6640,7 +6619,7 @@ def __init__( *, command_id: str, script: Optional[List[str]] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, **kwargs ): """ @@ -6721,7 +6700,7 @@ class RunCommandListResult(msrest.serialization.Model): def __init__( self, *, - value: List["RunCommandDocumentBase"], + value: List["_models.RunCommandDocumentBase"], next_link: Optional[str] = None, **kwargs ): @@ -6804,7 +6783,7 @@ class RunCommandResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["InstanceViewStatus"]] = None, + value: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -6848,7 +6827,7 @@ class ScaleInPolicy(msrest.serialization.Model): def __init__( self, *, - rules: Optional[List[Union[str, "VirtualMachineScaleSetScaleInRules"]]] = None, + rules: Optional[List[Union[str, "_models.VirtualMachineScaleSetScaleInRules"]]] = None, force_deletion: Optional[bool] = None, **kwargs ): @@ -6895,7 +6874,7 @@ class ScheduledEventsProfile(msrest.serialization.Model): def __init__( self, *, - terminate_notification_profile: Optional["TerminateNotificationProfile"] = None, + terminate_notification_profile: Optional["_models.TerminateNotificationProfile"] = None, **kwargs ): """ @@ -6922,8 +6901,7 @@ class SecurityProfile(msrest.serialization.Model): :vartype encryption_at_host: bool :ivar security_type: Specifies the SecurityType of the virtual machine. It has to be set to any specified value to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will not - be enabled unless this property is set. Possible values include: "TrustedLaunch", - "ConfidentialVM". + be enabled unless this property is set. Known values are: "TrustedLaunch", "ConfidentialVM". :vartype security_type: str or ~azure.mgmt.compute.v2022_03_01.models.SecurityTypes """ @@ -6936,9 +6914,9 @@ class SecurityProfile(msrest.serialization.Model): def __init__( self, *, - uefi_settings: Optional["UefiSettings"] = None, + uefi_settings: Optional["_models.UefiSettings"] = None, encryption_at_host: Optional[bool] = None, - security_type: Optional[Union[str, "SecurityTypes"]] = None, + security_type: Optional[Union[str, "_models.SecurityTypes"]] = None, **kwargs ): """ @@ -6953,7 +6931,7 @@ def __init__( :paramtype encryption_at_host: bool :keyword security_type: Specifies the SecurityType of the virtual machine. It has to be set to any specified value to enable UefiSettings. :code:`
`:code:`
` Default: UefiSettings will - not be enabled unless this property is set. Possible values include: "TrustedLaunch", + not be enabled unless this property is set. Known values are: "TrustedLaunch", "ConfidentialVM". :paramtype security_type: str or ~azure.mgmt.compute.v2022_03_01.models.SecurityTypes """ @@ -7057,7 +7035,7 @@ class SshConfiguration(msrest.serialization.Model): def __init__( self, *, - public_keys: Optional[List["SshPublicKey"]] = None, + public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -7252,7 +7230,7 @@ class SshPublicKeysGroupListResult(msrest.serialization.Model): def __init__( self, *, - value: List["SshPublicKeyResource"], + value: List["_models.SshPublicKeyResource"], next_link: Optional[str] = None, **kwargs ): @@ -7334,9 +7312,9 @@ class StorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["OSDisk"] = None, - data_disks: Optional[List["DataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.OSDisk"] = None, + data_disks: Optional[List["_models.DataDisk"]] = None, **kwargs ): """ @@ -7408,7 +7386,7 @@ def __init__( self, *, id: Optional[str] = None, - colocation_status: Optional["InstanceViewStatus"] = None, + colocation_status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -7621,7 +7599,7 @@ class UpgradeOperationHistoricalStatusInfoProperties(msrest.serialization.Model) :vartype progress: ~azure.mgmt.compute.v2022_03_01.models.RollingUpgradeProgressInfo :ivar error: Error Details for this upgrade if there are any. :vartype error: ~azure.mgmt.compute.v2022_03_01.models.ApiError - :ivar started_by: Invoker of the Upgrade Operation. Possible values include: "Unknown", "User", + :ivar started_by: Invoker of the Upgrade Operation. Known values are: "Unknown", "User", "Platform". :vartype started_by: str or ~azure.mgmt.compute.v2022_03_01.models.UpgradeOperationInvoker :ivar target_image_reference: Image Reference details. @@ -7668,7 +7646,7 @@ class UpgradeOperationHistoryStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar code: Code indicating the current status of the upgrade. Possible values include: + :ivar code: Code indicating the current status of the upgrade. Known values are: "RollingForward", "Cancelled", "Completed", "Faulted". :vartype code: str or ~azure.mgmt.compute.v2022_03_01.models.UpgradeState :ivar start_time: Start time of the upgrade. @@ -7708,8 +7686,8 @@ class UpgradePolicy(msrest.serialization.Model): />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :vartype mode: str or ~azure.mgmt.compute.v2022_03_01.models.UpgradeMode :ivar rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -7729,9 +7707,9 @@ class UpgradePolicy(msrest.serialization.Model): def __init__( self, *, - mode: Optional[Union[str, "UpgradeMode"]] = None, - rolling_upgrade_policy: Optional["RollingUpgradePolicy"] = None, - automatic_os_upgrade_policy: Optional["AutomaticOSUpgradePolicy"] = None, + mode: Optional[Union[str, "_models.UpgradeMode"]] = None, + rolling_upgrade_policy: Optional["_models.RollingUpgradePolicy"] = None, + automatic_os_upgrade_policy: Optional["_models.AutomaticOSUpgradePolicy"] = None, **kwargs ): """ @@ -7739,8 +7717,8 @@ def __init__( />`:code:`
` Possible values are::code:`
`:code:`
` **Manual** - You control the application of updates to virtual machines in the scale set. You do this by using the manualUpgrade action.:code:`
`:code:`
` **Automatic** - All virtual machines in the - scale set are automatically updated at the same time. Possible values include: "Automatic", - "Manual", "Rolling". + scale set are automatically updated at the same time. Known values are: "Automatic", "Manual", + "Rolling". :paramtype mode: str or ~azure.mgmt.compute.v2022_03_01.models.UpgradeMode :keyword rolling_upgrade_policy: The configuration parameters used while performing a rolling upgrade. @@ -7794,7 +7772,7 @@ def __init__( *, current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ @@ -7956,8 +7934,8 @@ class VaultSecretGroup(msrest.serialization.Model): def __init__( self, *, - source_vault: Optional["SubResource"] = None, - vault_certificates: Optional[List["VaultCertificate"]] = None, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.VaultCertificate"]] = None, **kwargs ): """ @@ -8074,14 +8052,13 @@ class VirtualMachine(Resource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2022_03_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -8200,32 +8177,32 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, platform_fault_domain: Optional[int] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, - capacity_reservation: Optional["CapacityReservationProfile"] = None, - application_profile: Optional["ApplicationProfile"] = None, + capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, + application_profile: Optional["_models.ApplicationProfile"] = None, **kwargs ): """ @@ -8291,15 +8268,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2022_03_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -8407,8 +8383,8 @@ def __init__( self, *, vm_agent_version: Optional[str] = None, - extension_handlers: Optional[List["VirtualMachineExtensionHandlerInstanceView"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + extension_handlers: Optional[List["_models.VirtualMachineExtensionHandlerInstanceView"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -8433,8 +8409,8 @@ class VirtualMachineAssessPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", - or "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2022_03_01.models.PatchOperationStatus :ivar assessment_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. @@ -8687,7 +8663,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, suppress_failures: Optional[bool] = None, protected_settings_from_key_vault: Optional[Any] = None, **kwargs @@ -8767,7 +8743,7 @@ def __init__( *, type: Optional[str] = None, type_handler_version: Optional[str] = None, - status: Optional["InstanceViewStatus"] = None, + status: Optional["_models.InstanceViewStatus"] = None, **kwargs ): """ @@ -8904,8 +8880,8 @@ def __init__( name: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, - substatuses: Optional[List["InstanceViewStatus"]] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + substatuses: Optional[List["_models.InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -8942,7 +8918,7 @@ class VirtualMachineExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineExtension"]] = None, + value: Optional[List["_models.VirtualMachineExtension"]] = None, **kwargs ): """ @@ -9103,8 +9079,8 @@ class VirtualMachineIdentity(msrest.serialization.Model): :vartype tenant_id: str :ivar type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2022_03_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -9128,15 +9104,15 @@ class VirtualMachineIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned - identities. The type 'None' will remove any identities from the virtual machine. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + identities. The type 'None' will remove any identities from the virtual machine. Known values + are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2022_03_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the Virtual Machine. The user identity dictionary key references will be ARM resource ids in the form: @@ -9190,7 +9166,7 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, **kwargs ): """ @@ -9241,8 +9217,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :ivar automatic_os_upgrade_properties: Describes automatic OS upgrade properties on the image. :vartype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2022_03_01.models.AutomaticOSUpgradeProperties - :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: "V1", - "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_01.models.HyperVGenerationTypes :ivar disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -9250,7 +9225,7 @@ class VirtualMachineImage(VirtualMachineImageResource): :vartype disallowed: ~azure.mgmt.compute.v2022_03_01.models.DisallowedConfiguration :ivar features: :vartype features: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageFeature] - :ivar architecture: Specifies the Architecture Type. Possible values include: "x64", "Arm64". + :ivar architecture: Specifies the Architecture Type. Known values are: "x64", "Arm64". :vartype architecture: str or ~azure.mgmt.compute.v2022_03_01.models.ArchitectureTypes """ @@ -9282,15 +9257,15 @@ def __init__( location: str, id: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - plan: Optional["PurchasePlan"] = None, - os_disk_image: Optional["OSDiskImage"] = None, - data_disk_images: Optional[List["DataDiskImage"]] = None, - automatic_os_upgrade_properties: Optional["AutomaticOSUpgradeProperties"] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationTypes"]] = None, - disallowed: Optional["DisallowedConfiguration"] = None, - features: Optional[List["VirtualMachineImageFeature"]] = None, - architecture: Optional[Union[str, "ArchitectureTypes"]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + plan: Optional["_models.PurchasePlan"] = None, + os_disk_image: Optional["_models.OSDiskImage"] = None, + data_disk_images: Optional[List["_models.DataDiskImage"]] = None, + automatic_os_upgrade_properties: Optional["_models.AutomaticOSUpgradeProperties"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationTypes"]] = None, + disallowed: Optional["_models.DisallowedConfiguration"] = None, + features: Optional[List["_models.VirtualMachineImageFeature"]] = None, + architecture: Optional[Union[str, "_models.ArchitectureTypes"]] = None, **kwargs ): """ @@ -9317,8 +9292,7 @@ def __init__( image. :paramtype automatic_os_upgrade_properties: ~azure.mgmt.compute.v2022_03_01.models.AutomaticOSUpgradeProperties - :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Possible values include: - "V1", "V2". + :keyword hyper_v_generation: Specifies the HyperVGeneration Type. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_01.models.HyperVGenerationTypes :keyword disallowed: Specifies disallowed configuration for the VirtualMachine created from the @@ -9326,8 +9300,7 @@ def __init__( :paramtype disallowed: ~azure.mgmt.compute.v2022_03_01.models.DisallowedConfiguration :keyword features: :paramtype features: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageFeature] - :keyword architecture: Specifies the Architecture Type. Possible values include: "x64", - "Arm64". + :keyword architecture: Specifies the Architecture Type. Known values are: "x64", "Arm64". :paramtype architecture: str or ~azure.mgmt.compute.v2022_03_01.models.ArchitectureTypes """ super(VirtualMachineImage, self).__init__(id=id, name=name, location=location, tags=tags, extended_location=extended_location, **kwargs) @@ -9382,7 +9355,7 @@ class VirtualMachineInstallPatchesParameters(msrest.serialization.Model): must be an ISO 8601-compliant duration string such as PT4H (4 hours). :vartype maximum_duration: str :ivar reboot_setting: Required. Defines when it is acceptable to reboot a VM during a software - update operation. Possible values include: "IfRequired", "Never", "Always". + update operation. Known values are: "IfRequired", "Never", "Always". :vartype reboot_setting: str or ~azure.mgmt.compute.v2022_03_01.models.VMGuestPatchRebootSetting :ivar windows_parameters: Input for InstallPatches on a Windows VM, as directly received by the @@ -9407,10 +9380,10 @@ class VirtualMachineInstallPatchesParameters(msrest.serialization.Model): def __init__( self, *, - reboot_setting: Union[str, "VMGuestPatchRebootSetting"], + reboot_setting: Union[str, "_models.VMGuestPatchRebootSetting"], maximum_duration: Optional[str] = None, - windows_parameters: Optional["WindowsParameters"] = None, - linux_parameters: Optional["LinuxParameters"] = None, + windows_parameters: Optional["_models.WindowsParameters"] = None, + linux_parameters: Optional["_models.LinuxParameters"] = None, **kwargs ): """ @@ -9418,7 +9391,7 @@ def __init__( must be an ISO 8601-compliant duration string such as PT4H (4 hours). :paramtype maximum_duration: str :keyword reboot_setting: Required. Defines when it is acceptable to reboot a VM during a - software update operation. Possible values include: "IfRequired", "Never", "Always". + software update operation. Known values are: "IfRequired", "Never", "Always". :paramtype reboot_setting: str or ~azure.mgmt.compute.v2022_03_01.models.VMGuestPatchRebootSetting :keyword windows_parameters: Input for InstallPatches on a Windows VM, as directly received by @@ -9442,14 +9415,14 @@ class VirtualMachineInstallPatchesResult(msrest.serialization.Model): :ivar status: The overall success or failure status of the operation. It remains "InProgress" until the operation completes. At that point it will become "Failed", "Succeeded", "Unknown" or - "CompletedWithWarnings.". Possible values include: "Unknown", "InProgress", "Failed", - "Succeeded", "CompletedWithWarnings". + "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". :vartype status: str or ~azure.mgmt.compute.v2022_03_01.models.PatchOperationStatus :ivar installation_activity_id: The activity ID of the operation that produced this result. It is used to correlate across CRP and extension logs. :vartype installation_activity_id: str - :ivar reboot_status: The reboot state of the VM following completion of the operation. Possible - values include: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". + :ivar reboot_status: The reboot state of the VM following completion of the operation. Known + values are: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". :vartype reboot_status: str or ~azure.mgmt.compute.v2022_03_01.models.VMGuestPatchRebootStatus :ivar maintenance_window_exceeded: Whether the operation ran out of time before it completed all its intended actions. @@ -9544,8 +9517,8 @@ class VirtualMachineInstanceView(msrest.serialization.Model): :vartype os_name: str :ivar os_version: The version of Operating System running on the virtual machine. :vartype os_version: str - :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + :ivar hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. Known + values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_01.models.HyperVGenerationType :ivar rdp_thumb_print: The Remote desktop certificate thumbprint. :vartype rdp_thumb_print: str @@ -9609,15 +9582,15 @@ def __init__( computer_name: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, - hyper_v_generation: Optional[Union[str, "HyperVGenerationType"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGenerationType"]] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, - patch_status: Optional["VirtualMachinePatchStatus"] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, + patch_status: Optional["_models.VirtualMachinePatchStatus"] = None, **kwargs ): """ @@ -9632,7 +9605,7 @@ def __init__( :keyword os_version: The version of Operating System running on the virtual machine. :paramtype os_version: str :keyword hyper_v_generation: Specifies the HyperVGeneration Type associated with a resource. - Possible values include: "V1", "V2". + Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_01.models.HyperVGenerationType :keyword rdp_thumb_print: The Remote desktop certificate thumbprint. @@ -9732,7 +9705,7 @@ class VirtualMachineListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachine"], + value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs ): @@ -9759,7 +9732,7 @@ class VirtualMachineNetworkInterfaceConfiguration(msrest.serialization.Model): than 1 network interface. :vartype primary: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions :ivar enable_accelerated_networking: Specifies whether the network interface is accelerated networking-enabled. @@ -9802,14 +9775,14 @@ def __init__( *, name: str, primary: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, enable_ip_forwarding: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineNetworkInterfaceDnsSettingsConfiguration"] = None, - ip_configurations: Optional[List["VirtualMachineNetworkInterfaceIPConfiguration"]] = None, - dscp_configuration: Optional["SubResource"] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineNetworkInterfaceDnsSettingsConfiguration"] = None, + ip_configurations: Optional[List["_models.VirtualMachineNetworkInterfaceIPConfiguration"]] = None, + dscp_configuration: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -9819,7 +9792,7 @@ def __init__( than 1 network interface. :paramtype primary: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions :keyword enable_accelerated_networking: Specifies whether the network interface is accelerated networking-enabled. @@ -9894,7 +9867,7 @@ class VirtualMachineNetworkInterfaceIPConfiguration(msrest.serialization.Model): ~azure.mgmt.compute.v2022_03_01.models.VirtualMachinePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2022_03_01.models.IPVersions :ivar application_security_groups: Specifies an array of references to application security group. @@ -9932,13 +9905,13 @@ def __init__( self, *, name: str, - subnet: Optional["SubResource"] = None, + subnet: Optional["_models.SubResource"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachinePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersions"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachinePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersions"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -9954,7 +9927,7 @@ def __init__( ~azure.mgmt.compute.v2022_03_01.models.VirtualMachinePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2022_03_01.models.IPVersions :keyword application_security_groups: Specifies an array of references to application security group. @@ -10014,8 +9987,8 @@ class VirtualMachinePatchStatus(msrest.serialization.Model): def __init__( self, *, - available_patch_summary: Optional["AvailablePatchSummary"] = None, - last_patch_installation_summary: Optional["LastPatchInstallationSummary"] = None, + available_patch_summary: Optional["_models.AvailablePatchSummary"] = None, + last_patch_installation_summary: Optional["_models.LastPatchInstallationSummary"] = None, **kwargs ): """ @@ -10046,7 +10019,7 @@ class VirtualMachinePublicIPAddressConfiguration(msrest.serialization.Model): :ivar idle_timeout_in_minutes: The idle timeout of the public IP address. :vartype idle_timeout_in_minutes: int :ivar delete_option: Specify what happens to the public IP address when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions :ivar dns_settings: The dns settings to be applied on the publicIP addresses . :vartype dns_settings: @@ -10057,10 +10030,10 @@ class VirtualMachinePublicIPAddressConfiguration(msrest.serialization.Model): :vartype public_ip_prefix: ~azure.mgmt.compute.v2022_03_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2022_03_01.models.IPVersions - :ivar public_ip_allocation_method: Specify the public IP allocation type. Possible values - include: "Dynamic", "Static". + :ivar public_ip_allocation_method: Specify the public IP allocation type. Known values are: + "Dynamic", "Static". :vartype public_ip_allocation_method: str or ~azure.mgmt.compute.v2022_03_01.models.PublicIPAllocationMethod """ @@ -10085,14 +10058,14 @@ def __init__( self, *, name: str, - sku: Optional["PublicIPAddressSku"] = None, + sku: Optional["_models.PublicIPAddressSku"] = None, idle_timeout_in_minutes: Optional[int] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, - dns_settings: Optional["VirtualMachinePublicIPAddressDnsSettingsConfiguration"] = None, - ip_tags: Optional[List["VirtualMachineIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersions"]] = None, - public_ip_allocation_method: Optional[Union[str, "PublicIPAllocationMethod"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachinePublicIPAddressDnsSettingsConfiguration"] = None, + ip_tags: Optional[List["_models.VirtualMachineIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersions"]] = None, + public_ip_allocation_method: Optional[Union[str, "_models.PublicIPAllocationMethod"]] = None, **kwargs ): """ @@ -10104,7 +10077,7 @@ def __init__( :keyword idle_timeout_in_minutes: The idle timeout of the public IP address. :paramtype idle_timeout_in_minutes: int :keyword delete_option: Specify what happens to the public IP address when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions :keyword dns_settings: The dns settings to be applied on the publicIP addresses . :paramtype dns_settings: @@ -10115,10 +10088,10 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2022_03_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2022_03_01.models.IPVersions - :keyword public_ip_allocation_method: Specify the public IP allocation type. Possible values - include: "Dynamic", "Static". + :keyword public_ip_allocation_method: Specify the public IP allocation type. Known values are: + "Dynamic", "Static". :paramtype public_ip_allocation_method: str or ~azure.mgmt.compute.v2022_03_01.models.PublicIPAllocationMethod """ @@ -10276,9 +10249,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -10333,7 +10306,7 @@ def __init__( class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): """The instance view of a virtual machine run command. - :ivar execution_state: Script execution status. Possible values include: "Unknown", "Pending", + :ivar execution_state: Script execution status. Known values are: "Unknown", "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :vartype execution_state: str or ~azure.mgmt.compute.v2022_03_01.models.ExecutionState :ivar execution_message: Communicate script configuration errors or execution messages. @@ -10366,19 +10339,19 @@ class VirtualMachineRunCommandInstanceView(msrest.serialization.Model): def __init__( self, *, - execution_state: Optional[Union[str, "ExecutionState"]] = None, + execution_state: Optional[Union[str, "_models.ExecutionState"]] = None, execution_message: Optional[str] = None, exit_code: Optional[int] = None, output: Optional[str] = None, error: Optional[str] = None, start_time: Optional[datetime.datetime] = None, end_time: Optional[datetime.datetime] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ - :keyword execution_state: Script execution status. Possible values include: "Unknown", - "Pending", "Running", "Failed", "Succeeded", "TimedOut", "Canceled". + :keyword execution_state: Script execution status. Known values are: "Unknown", "Pending", + "Running", "Failed", "Succeeded", "TimedOut", "Canceled". :paramtype execution_state: str or ~azure.mgmt.compute.v2022_03_01.models.ExecutionState :keyword execution_message: Communicate script configuration errors or execution messages. :paramtype execution_message: str @@ -10468,7 +10441,7 @@ class VirtualMachineRunCommandsListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineRunCommand"], + value: List["_models.VirtualMachineRunCommand"], next_link: Optional[str] = None, **kwargs ): @@ -10544,9 +10517,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - source: Optional["VirtualMachineRunCommandScriptSource"] = None, - parameters: Optional[List["RunCommandInputParameter"]] = None, - protected_parameters: Optional[List["RunCommandInputParameter"]] = None, + source: Optional["_models.VirtualMachineRunCommandScriptSource"] = None, + parameters: Optional[List["_models.RunCommandInputParameter"]] = None, + protected_parameters: Optional[List["_models.RunCommandInputParameter"]] = None, async_execution: Optional[bool] = False, run_as_user: Optional[str] = None, run_as_password: Optional[str] = None, @@ -10673,7 +10646,7 @@ class VirtualMachineScaleSet(Resource): Virtual Machine Scale Set. :vartype scale_in_policy: ~azure.mgmt.compute.v2022_03_01.models.ScaleInPolicy :ivar orchestration_mode: Specifies the orchestration mode for the virtual machine scale set. - Possible values include: "Uniform", "Flexible". + Known values are: "Uniform", "Flexible". :vartype orchestration_mode: str or ~azure.mgmt.compute.v2022_03_01.models.OrchestrationMode :ivar spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale set. @@ -10728,25 +10701,25 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetVMProfile"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, zone_balance: Optional[bool] = None, platform_fault_domain_count: Optional[int] = None, - proximity_placement_group: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - orchestration_mode: Optional[Union[str, "OrchestrationMode"]] = None, - spot_restore_policy: Optional["SpotRestorePolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + orchestration_mode: Optional[Union[str, "_models.OrchestrationMode"]] = None, + spot_restore_policy: Optional["_models.SpotRestorePolicy"] = None, **kwargs ): """ @@ -10812,7 +10785,7 @@ def __init__( the Virtual Machine Scale Set. :paramtype scale_in_policy: ~azure.mgmt.compute.v2022_03_01.models.ScaleInPolicy :keyword orchestration_mode: Specifies the orchestration mode for the virtual machine scale - set. Possible values include: "Uniform", "Flexible". + set. Known values are: "Uniform", "Flexible". :paramtype orchestration_mode: str or ~azure.mgmt.compute.v2022_03_01.models.OrchestrationMode :keyword spot_restore_policy: Specifies the Spot Restore properties for the virtual machine scale set. @@ -10857,14 +10830,13 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :vartype write_accelerator_enabled: bool - :ivar create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :ivar create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskCreateOptionTypes :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -10887,7 +10859,7 @@ class VirtualMachineScaleSetDataDisk(msrest.serialization.Model): value is used, the data disk is deleted when the VMSS Flex VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the data disk is retained after VMSS Flex VM is deleted.:code:`
`:code:`
` The default value is set to **Delete**. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskDeleteOptionTypes """ @@ -10913,15 +10885,15 @@ def __init__( self, *, lun: int, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ @@ -10934,14 +10906,13 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. :paramtype write_accelerator_enabled: bool - :keyword create_option: Required. The create option. Possible values include: "FromImage", - "Empty", "Attach". + :keyword create_option: Required. The create option. Known values are: "FromImage", "Empty", + "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskCreateOptionTypes :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. :code:`
`:code:`
` @@ -10964,7 +10935,7 @@ def __init__( value is used, the data disk is deleted when the VMSS Flex VM is deleted.:code:`
`:code:`
` **Detach** If this value is used, the data disk is retained after VMSS Flex VM is deleted.:code:`
`:code:`
` The default value is set to **Delete**. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskDeleteOptionTypes """ super(VirtualMachineScaleSetDataDisk, self).__init__(**kwargs) @@ -11145,7 +11116,7 @@ class VirtualMachineScaleSetExtensionListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetExtension"], + value: List["_models.VirtualMachineScaleSetExtension"], next_link: Optional[str] = None, **kwargs ): @@ -11182,7 +11153,7 @@ class VirtualMachineScaleSetExtensionProfile(msrest.serialization.Model): def __init__( self, *, - extensions: Optional[List["VirtualMachineScaleSetExtension"]] = None, + extensions: Optional[List["_models.VirtualMachineScaleSetExtension"]] = None, extensions_time_budget: Optional[str] = None, **kwargs ): @@ -11356,7 +11327,7 @@ class VirtualMachineScaleSetHardwareProfile(msrest.serialization.Model): def __init__( self, *, - vm_size_properties: Optional["VMSizeProperties"] = None, + vm_size_properties: Optional["_models.VMSizeProperties"] = None, **kwargs ): """ @@ -11383,7 +11354,7 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): :ivar type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2022_03_01.models.ResourceIdentityType :ivar user_assigned_identities: The list of user identities associated with the virtual machine @@ -11408,15 +11379,15 @@ class VirtualMachineScaleSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of identity used for the virtual machine scale set. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the virtual machine scale - set. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + set. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2022_03_01.models.ResourceIdentityType :keyword user_assigned_identities: The list of user identities associated with the virtual @@ -11467,7 +11438,7 @@ class VirtualMachineScaleSetInstanceView(msrest.serialization.Model): def __init__( self, *, - statuses: Optional[List["InstanceViewStatus"]] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, **kwargs ): """ @@ -11528,7 +11499,7 @@ class VirtualMachineScaleSetIPConfiguration(SubResource): ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2022_03_01.models.IPVersion :ivar application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -11572,14 +11543,14 @@ def __init__( *, name: str, id: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -11597,7 +11568,7 @@ def __init__( ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetPublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2022_03_01.models.IPVersion :keyword application_gateway_backend_address_pools: Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of @@ -11689,7 +11660,7 @@ class VirtualMachineScaleSetListOSUpgradeHistory(msrest.serialization.Model): def __init__( self, *, - value: List["UpgradeOperationHistoricalStatusInfo"], + value: List["_models.UpgradeOperationHistoricalStatusInfo"], next_link: Optional[str] = None, **kwargs ): @@ -11730,7 +11701,7 @@ class VirtualMachineScaleSetListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -11770,7 +11741,7 @@ class VirtualMachineScaleSetListSkusResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetSku"], + value: List["_models.VirtualMachineScaleSetSku"], next_link: Optional[str] = None, **kwargs ): @@ -11810,7 +11781,7 @@ class VirtualMachineScaleSetListWithLinkResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSet"], + value: List["_models.VirtualMachineScaleSet"], next_link: Optional[str] = None, **kwargs ): @@ -11830,8 +11801,8 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): """Describes the parameters of a ScaleSet managed disk. :ivar storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". :vartype storage_account_type: str or ~azure.mgmt.compute.v2022_03_01.models.StorageAccountTypes @@ -11852,15 +11823,15 @@ class VirtualMachineScaleSetManagedDiskParameters(msrest.serialization.Model): def __init__( self, *, - storage_account_type: Optional[Union[str, "StorageAccountTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, - security_profile: Optional["VMDiskSecurityProfile"] = None, + storage_account_type: Optional[Union[str, "_models.StorageAccountTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, + security_profile: Optional["_models.VMDiskSecurityProfile"] = None, **kwargs ): """ :keyword storage_account_type: Specifies the storage account type for the managed disk. NOTE: - UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values - include: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", + UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Known values + are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". :paramtype storage_account_type: str or ~azure.mgmt.compute.v2022_03_01.models.StorageAccountTypes @@ -11905,7 +11876,7 @@ class VirtualMachineScaleSetNetworkConfiguration(SubResource): :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions """ @@ -11934,11 +11905,11 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -11965,7 +11936,7 @@ def __init__( :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions """ super(VirtualMachineScaleSetNetworkConfiguration, self).__init__(id=id, **kwargs) @@ -12017,7 +11988,7 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetNetworkConfiguration] :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2022_03_01.models.NetworkApiVersion """ @@ -12030,9 +12001,9 @@ class VirtualMachineScaleSetNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, **kwargs ): """ @@ -12045,7 +12016,7 @@ def __init__( list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetNetworkConfiguration] :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2022_03_01.models.NetworkApiVersion """ super(VirtualMachineScaleSetNetworkProfile, self).__init__(**kwargs) @@ -12064,8 +12035,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :ivar caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -12074,8 +12044,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :vartype create_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskCreateOptionTypes :ivar diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -12086,8 +12056,8 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): :vartype disk_size_gb: int :ivar os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible - values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Possible - values include: "Windows", "Linux". + values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. Known + values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemTypes :ivar image: Specifies information about the unmanaged user image to base the scale set on. :vartype image: ~azure.mgmt.compute.v2022_03_01.models.VirtualHardDisk @@ -12104,7 +12074,7 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): If this value is used, the OS disk is retained after VMSS Flex VM is deleted. :code:`
`:code:`
` The default value is set to **Delete**. For an Ephemeral OS Disk, the default value is set to **Delete**. User cannot change the delete option for Ephemeral OS Disk. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskDeleteOptionTypes """ @@ -12129,17 +12099,17 @@ class VirtualMachineScaleSetOSDisk(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOptionTypes"], + create_option: Union[str, "_models.DiskCreateOptionTypes"], name: Optional[str] = None, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, - diff_disk_settings: Optional["DiffDiskSettings"] = None, + diff_disk_settings: Optional["_models.DiffDiskSettings"] = None, disk_size_gb: Optional[int] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - image: Optional["VirtualHardDisk"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ @@ -12148,8 +12118,7 @@ def __init__( :keyword caching: Specifies the caching requirements. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **None** :code:`
`:code:`
` **ReadOnly** :code:`
`:code:`
` **ReadWrite** :code:`
`:code:`
` Default: **None for Standard - storage. ReadOnly for Premium storage**. Possible values include: "None", "ReadOnly", - "ReadWrite". + storage. ReadOnly for Premium storage**. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -12158,8 +12127,8 @@ def __init__( created.:code:`
`:code:`
` The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace - image, you also use the plan element previously described. Possible values include: - "FromImage", "Empty", "Attach". + image, you also use the plan element previously described. Known values are: "FromImage", + "Empty", "Attach". :paramtype create_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskCreateOptionTypes :keyword diff_disk_settings: Specifies the ephemeral disk Settings for the operating system disk used by the virtual machine scale set. @@ -12171,7 +12140,7 @@ def __init__( :keyword os_type: This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD. :code:`
`:code:`
` Possible values are: :code:`
`:code:`
` **Windows** :code:`
`:code:`
` **Linux**. - Possible values include: "Windows", "Linux". + Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_01.models.OperatingSystemTypes :keyword image: Specifies information about the unmanaged user image to base the scale set on. :paramtype image: ~azure.mgmt.compute.v2022_03_01.models.VirtualHardDisk @@ -12188,7 +12157,7 @@ def __init__( If this value is used, the OS disk is retained after VMSS Flex VM is deleted. :code:`
`:code:`
` The default value is set to **Delete**. For an Ephemeral OS Disk, the default value is set to **Delete**. User cannot change the delete option for Ephemeral OS Disk. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskDeleteOptionTypes """ super(VirtualMachineScaleSetOSDisk, self).__init__(**kwargs) @@ -12280,9 +12249,9 @@ def __init__( admin_username: Optional[str] = None, admin_password: Optional[str] = None, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, allow_extension_operations: Optional[bool] = None, **kwargs ): @@ -12372,10 +12341,10 @@ class VirtualMachineScaleSetPublicIPAddressConfiguration(msrest.serialization.Mo :vartype public_ip_prefix: ~azure.mgmt.compute.v2022_03_01.models.SubResource :ivar public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible values - are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype public_ip_address_version: str or ~azure.mgmt.compute.v2022_03_01.models.IPVersion - :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values + are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions """ @@ -12398,13 +12367,13 @@ def __init__( self, *, name: str, - sku: Optional["PublicIPAddressSku"] = None, + sku: Optional["_models.PublicIPAddressSku"] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - ip_tags: Optional[List["VirtualMachineScaleSetIpTag"]] = None, - public_ip_prefix: Optional["SubResource"] = None, - public_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + ip_tags: Optional[List["_models.VirtualMachineScaleSetIpTag"]] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + public_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -12424,10 +12393,10 @@ def __init__( :paramtype public_ip_prefix: ~azure.mgmt.compute.v2022_03_01.models.SubResource :keyword public_ip_address_version: Available from Api-Version 2019-07-01 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype public_ip_address_version: str or ~azure.mgmt.compute.v2022_03_01.models.IPVersion - :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known + values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions """ super(VirtualMachineScaleSetPublicIPAddressConfiguration, self).__init__(**kwargs) @@ -12587,8 +12556,7 @@ class VirtualMachineScaleSetSkuCapacity(msrest.serialization.Model): :vartype maximum: long :ivar default_capacity: The default capacity. :vartype default_capacity: long - :ivar scale_type: The scale type applicable to the sku. Possible values include: "Automatic", - "None". + :ivar scale_type: The scale type applicable to the sku. Known values are: "Automatic", "None". :vartype scale_type: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetSkuScaleType """ @@ -12650,9 +12618,9 @@ class VirtualMachineScaleSetStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -12743,18 +12711,18 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["Sku"] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineScaleSetIdentity"] = None, - upgrade_policy: Optional["UpgradePolicy"] = None, - automatic_repairs_policy: Optional["AutomaticRepairsPolicy"] = None, - virtual_machine_profile: Optional["VirtualMachineScaleSetUpdateVMProfile"] = None, + sku: Optional["_models.Sku"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineScaleSetIdentity"] = None, + upgrade_policy: Optional["_models.UpgradePolicy"] = None, + automatic_repairs_policy: Optional["_models.AutomaticRepairsPolicy"] = None, + virtual_machine_profile: Optional["_models.VirtualMachineScaleSetUpdateVMProfile"] = None, overprovision: Optional[bool] = None, do_not_run_extensions_on_overprovisioned_v_ms: Optional[bool] = None, single_placement_group: Optional[bool] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - scale_in_policy: Optional["ScaleInPolicy"] = None, - proximity_placement_group: Optional["SubResource"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + scale_in_policy: Optional["_models.ScaleInPolicy"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, **kwargs ): """ @@ -12832,7 +12800,7 @@ class VirtualMachineScaleSetUpdateIPConfiguration(SubResource): ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :ivar private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible - values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :vartype private_ip_address_version: str or ~azure.mgmt.compute.v2022_03_01.models.IPVersion :ivar application_gateway_backend_address_pools: The application gateway backend address pools. :vartype application_gateway_backend_address_pools: @@ -12866,14 +12834,14 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - subnet: Optional["ApiEntityReference"] = None, + subnet: Optional["_models.ApiEntityReference"] = None, primary: Optional[bool] = None, - public_ip_address_configuration: Optional["VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, - private_ip_address_version: Optional[Union[str, "IPVersion"]] = None, - application_gateway_backend_address_pools: Optional[List["SubResource"]] = None, - application_security_groups: Optional[List["SubResource"]] = None, - load_balancer_backend_address_pools: Optional[List["SubResource"]] = None, - load_balancer_inbound_nat_pools: Optional[List["SubResource"]] = None, + public_ip_address_configuration: Optional["_models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration"] = None, + private_ip_address_version: Optional[Union[str, "_models.IPVersion"]] = None, + application_gateway_backend_address_pools: Optional[List["_models.SubResource"]] = None, + application_security_groups: Optional[List["_models.SubResource"]] = None, + load_balancer_backend_address_pools: Optional[List["_models.SubResource"]] = None, + load_balancer_inbound_nat_pools: Optional[List["_models.SubResource"]] = None, **kwargs ): """ @@ -12891,7 +12859,7 @@ def __init__( ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetUpdatePublicIPAddressConfiguration :keyword private_ip_address_version: Available from Api-Version 2017-03-30 onwards, it represents whether the specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. - Possible values are: 'IPv4' and 'IPv6'. Possible values include: "IPv4", "IPv6". + Possible values are: 'IPv4' and 'IPv6'. Known values are: "IPv4", "IPv6". :paramtype private_ip_address_version: str or ~azure.mgmt.compute.v2022_03_01.models.IPVersion :keyword application_gateway_backend_address_pools: The application gateway backend address pools. @@ -12945,7 +12913,7 @@ class VirtualMachineScaleSetUpdateNetworkConfiguration(SubResource): :ivar enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :vartype enable_ip_forwarding: bool :ivar delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions """ @@ -12970,11 +12938,11 @@ def __init__( primary: Optional[bool] = None, enable_accelerated_networking: Optional[bool] = None, enable_fpga: Optional[bool] = None, - network_security_group: Optional["SubResource"] = None, - dns_settings: Optional["VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, - ip_configurations: Optional[List["VirtualMachineScaleSetUpdateIPConfiguration"]] = None, + network_security_group: Optional["_models.SubResource"] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetNetworkConfigurationDnsSettings"] = None, + ip_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateIPConfiguration"]] = None, enable_ip_forwarding: Optional[bool] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -13000,7 +12968,7 @@ def __init__( :keyword enable_ip_forwarding: Whether IP forwarding enabled on this NIC. :paramtype enable_ip_forwarding: bool :keyword delete_option: Specify what happens to the network interface when the VM is deleted. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions """ super(VirtualMachineScaleSetUpdateNetworkConfiguration, self).__init__(id=id, **kwargs) @@ -13027,7 +12995,7 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] :ivar network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :vartype network_api_version: str or ~azure.mgmt.compute.v2022_03_01.models.NetworkApiVersion """ @@ -13040,9 +13008,9 @@ class VirtualMachineScaleSetUpdateNetworkProfile(msrest.serialization.Model): def __init__( self, *, - health_probe: Optional["ApiEntityReference"] = None, - network_interface_configurations: Optional[List["VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, - network_api_version: Optional[Union[str, "NetworkApiVersion"]] = None, + health_probe: Optional["_models.ApiEntityReference"] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetUpdateNetworkConfiguration"]] = None, + network_api_version: Optional[Union[str, "_models.NetworkApiVersion"]] = None, **kwargs ): """ @@ -13055,7 +13023,7 @@ def __init__( list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetUpdateNetworkConfiguration] :keyword network_api_version: specifies the Microsoft.Network API version used when creating networking resources in the Network Interface Configurations for Virtual Machine Scale Set with - orchestration mode 'Flexible'. Possible values include: "2020-11-01". + orchestration mode 'Flexible'. Known values are: "2020-11-01". :paramtype network_api_version: str or ~azure.mgmt.compute.v2022_03_01.models.NetworkApiVersion """ super(VirtualMachineScaleSetUpdateNetworkProfile, self).__init__(**kwargs) @@ -13067,7 +13035,7 @@ def __init__( class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): """Describes virtual machine scale set operating system disk Update Object. This should be used for Updating VMSS OS Disk. - :ivar caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :ivar caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :vartype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :ivar write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -13092,7 +13060,7 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): If this value is used, the OS disk is retained after VMSS Flex VM is deleted. :code:`
`:code:`
` The default value is set to **Delete**. For an Ephemeral OS Disk, the default value is set to **Delete**. User cannot change the delete option for Ephemeral OS Disk. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskDeleteOptionTypes """ @@ -13109,17 +13077,17 @@ class VirtualMachineScaleSetUpdateOSDisk(msrest.serialization.Model): def __init__( self, *, - caching: Optional[Union[str, "CachingTypes"]] = None, + caching: Optional[Union[str, "_models.CachingTypes"]] = None, write_accelerator_enabled: Optional[bool] = None, disk_size_gb: Optional[int] = None, - image: Optional["VirtualHardDisk"] = None, + image: Optional["_models.VirtualHardDisk"] = None, vhd_containers: Optional[List[str]] = None, - managed_disk: Optional["VirtualMachineScaleSetManagedDiskParameters"] = None, - delete_option: Optional[Union[str, "DiskDeleteOptionTypes"]] = None, + managed_disk: Optional["_models.VirtualMachineScaleSetManagedDiskParameters"] = None, + delete_option: Optional[Union[str, "_models.DiskDeleteOptionTypes"]] = None, **kwargs ): """ - :keyword caching: The caching type. Possible values include: "None", "ReadOnly", "ReadWrite". + :keyword caching: The caching type. Known values are: "None", "ReadOnly", "ReadWrite". :paramtype caching: str or ~azure.mgmt.compute.v2022_03_01.models.CachingTypes :keyword write_accelerator_enabled: Specifies whether writeAccelerator should be enabled or disabled on the disk. @@ -13144,7 +13112,7 @@ def __init__( If this value is used, the OS disk is retained after VMSS Flex VM is deleted. :code:`
`:code:`
` The default value is set to **Delete**. For an Ephemeral OS Disk, the default value is set to **Delete**. User cannot change the delete option for Ephemeral OS Disk. - Possible values include: "Delete", "Detach". + Known values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DiskDeleteOptionTypes """ super(VirtualMachineScaleSetUpdateOSDisk, self).__init__(**kwargs) @@ -13181,9 +13149,9 @@ def __init__( self, *, custom_data: Optional[str] = None, - windows_configuration: Optional["WindowsConfiguration"] = None, - linux_configuration: Optional["LinuxConfiguration"] = None, - secrets: Optional[List["VaultSecretGroup"]] = None, + windows_configuration: Optional["_models.WindowsConfiguration"] = None, + linux_configuration: Optional["_models.LinuxConfiguration"] = None, + secrets: Optional[List["_models.VaultSecretGroup"]] = None, **kwargs ): """ @@ -13215,8 +13183,8 @@ class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration(msrest.serializat ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings :ivar public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. :vartype public_ip_prefix: ~azure.mgmt.compute.v2022_03_01.models.SubResource - :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :ivar delete_option: Specify what happens to the public IP when the VM is deleted. Known values + are: "Delete", "Detach". :vartype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions """ @@ -13233,9 +13201,9 @@ def __init__( *, name: Optional[str] = None, idle_timeout_in_minutes: Optional[int] = None, - dns_settings: Optional["VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, - public_ip_prefix: Optional["SubResource"] = None, - delete_option: Optional[Union[str, "DeleteOptions"]] = None, + dns_settings: Optional["_models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings"] = None, + public_ip_prefix: Optional["_models.SubResource"] = None, + delete_option: Optional[Union[str, "_models.DeleteOptions"]] = None, **kwargs ): """ @@ -13248,8 +13216,8 @@ def __init__( ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings :keyword public_ip_prefix: The PublicIPPrefix from which to allocate publicIP addresses. :paramtype public_ip_prefix: ~azure.mgmt.compute.v2022_03_01.models.SubResource - :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Possible - values include: "Delete", "Detach". + :keyword delete_option: Specify what happens to the public IP when the VM is deleted. Known + values are: "Delete", "Detach". :paramtype delete_option: str or ~azure.mgmt.compute.v2022_03_01.models.DeleteOptions """ super(VirtualMachineScaleSetUpdatePublicIPAddressConfiguration, self).__init__(**kwargs) @@ -13281,9 +13249,9 @@ class VirtualMachineScaleSetUpdateStorageProfile(msrest.serialization.Model): def __init__( self, *, - image_reference: Optional["ImageReference"] = None, - os_disk: Optional["VirtualMachineScaleSetUpdateOSDisk"] = None, - data_disks: Optional[List["VirtualMachineScaleSetDataDisk"]] = None, + image_reference: Optional["_models.ImageReference"] = None, + os_disk: Optional["_models.VirtualMachineScaleSetUpdateOSDisk"] = None, + data_disks: Optional[List["_models.VirtualMachineScaleSetDataDisk"]] = None, **kwargs ): """ @@ -13349,15 +13317,15 @@ class VirtualMachineScaleSetUpdateVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetUpdateOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetUpdateStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetUpdateNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetUpdateOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetUpdateStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetUpdateNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, **kwargs ): @@ -13553,19 +13521,19 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - network_profile_configuration: Optional["VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + network_profile_configuration: Optional["_models.VirtualMachineScaleSetVMNetworkProfileConfiguration"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, - protection_policy: Optional["VirtualMachineScaleSetVMProtectionPolicy"] = None, + protection_policy: Optional["_models.VirtualMachineScaleSetVMProtectionPolicy"] = None, user_data: Optional[str] = None, **kwargs ): @@ -13743,7 +13711,7 @@ def __init__( enable_automatic_upgrade: Optional[bool] = None, settings: Optional[Any] = None, protected_settings: Optional[Any] = None, - instance_view: Optional["VirtualMachineExtensionInstanceView"] = None, + instance_view: Optional["_models.VirtualMachineExtensionInstanceView"] = None, suppress_failures: Optional[bool] = None, protected_settings_from_key_vault: Optional[Any] = None, **kwargs @@ -13813,7 +13781,7 @@ class VirtualMachineScaleSetVMExtensionsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineScaleSetVMExtension"]] = None, + value: Optional[List["_models.VirtualMachineScaleSetVMExtension"]] = None, **kwargs ): """ @@ -14109,12 +14077,12 @@ def __init__( platform_update_domain: Optional[int] = None, platform_fault_domain: Optional[int] = None, rdp_thumb_print: Optional[str] = None, - vm_agent: Optional["VirtualMachineAgentInstanceView"] = None, - maintenance_redeploy_status: Optional["MaintenanceRedeployStatus"] = None, - disks: Optional[List["DiskInstanceView"]] = None, - extensions: Optional[List["VirtualMachineExtensionInstanceView"]] = None, - boot_diagnostics: Optional["BootDiagnosticsInstanceView"] = None, - statuses: Optional[List["InstanceViewStatus"]] = None, + vm_agent: Optional["_models.VirtualMachineAgentInstanceView"] = None, + maintenance_redeploy_status: Optional["_models.MaintenanceRedeployStatus"] = None, + disks: Optional[List["_models.DiskInstanceView"]] = None, + extensions: Optional[List["_models.VirtualMachineExtensionInstanceView"]] = None, + boot_diagnostics: Optional["_models.BootDiagnosticsInstanceView"] = None, + statuses: Optional[List["_models.InstanceViewStatus"]] = None, placement_group_id: Optional[str] = None, **kwargs ): @@ -14185,7 +14153,7 @@ class VirtualMachineScaleSetVMListResult(msrest.serialization.Model): def __init__( self, *, - value: List["VirtualMachineScaleSetVM"], + value: List["_models.VirtualMachineScaleSetVM"], next_link: Optional[str] = None, **kwargs ): @@ -14216,7 +14184,7 @@ class VirtualMachineScaleSetVMNetworkProfileConfiguration(msrest.serialization.M def __init__( self, *, - network_interface_configurations: Optional[List["VirtualMachineScaleSetNetworkConfiguration"]] = None, + network_interface_configurations: Optional[List["_models.VirtualMachineScaleSetNetworkConfiguration"]] = None, **kwargs ): """ @@ -14263,15 +14231,14 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): :code:`
`:code:`
` Minimum api-version: 2015-06-15. :vartype license_type: str :ivar priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -14318,21 +14285,21 @@ class VirtualMachineScaleSetVMProfile(msrest.serialization.Model): def __init__( self, *, - os_profile: Optional["VirtualMachineScaleSetOSProfile"] = None, - storage_profile: Optional["VirtualMachineScaleSetStorageProfile"] = None, - network_profile: Optional["VirtualMachineScaleSetNetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - extension_profile: Optional["VirtualMachineScaleSetExtensionProfile"] = None, + os_profile: Optional["_models.VirtualMachineScaleSetOSProfile"] = None, + storage_profile: Optional["_models.VirtualMachineScaleSetStorageProfile"] = None, + network_profile: Optional["_models.VirtualMachineScaleSetNetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + extension_profile: Optional["_models.VirtualMachineScaleSetExtensionProfile"] = None, license_type: Optional[str] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, - capacity_reservation: Optional["CapacityReservationProfile"] = None, - application_profile: Optional["ApplicationProfile"] = None, - hardware_profile: Optional["VirtualMachineScaleSetHardwareProfile"] = None, + capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, + application_profile: Optional["_models.ApplicationProfile"] = None, + hardware_profile: Optional["_models.VirtualMachineScaleSetHardwareProfile"] = None, **kwargs ): """ @@ -14368,15 +14335,14 @@ def __init__( :code:`
`:code:`
` Minimum api-version: 2015-06-15. :paramtype license_type: str :keyword priority: Specifies the priority for the virtual machines in the scale set. - :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Possible values include: - "Regular", "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2017-10-30-preview. Known values are: "Regular", + "Low", "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot VMSS. @@ -14543,7 +14509,7 @@ class VirtualMachineSizeListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineSize"]] = None, + value: Optional[List["_models.VirtualMachineSize"]] = None, **kwargs ): """ @@ -14569,7 +14535,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype kb_id: str :ivar classifications: The classification(s) of the patch as provided by the patch publisher. :vartype classifications: list[str] - :ivar reboot_behavior: Describes the reboot requirements of the patch. Possible values include: + :ivar reboot_behavior: Describes the reboot requirements of the patch. Known values are: "Unknown", "NeverReboots", "AlwaysRequiresReboot", "CanRequestReboot". :vartype reboot_behavior: str or ~azure.mgmt.compute.v2022_03_01.models.VMGuestPatchRebootBehavior @@ -14580,7 +14546,7 @@ class VirtualMachineSoftwarePatchProperties(msrest.serialization.Model): :vartype published_date: ~datetime.datetime :ivar last_modified_date_time: The UTC timestamp of the last update to this patch record. :vartype last_modified_date_time: ~datetime.datetime - :ivar assessment_state: Describes the availability of a given patch. Possible values include: + :ivar assessment_state: Describes the availability of a given patch. Known values are: "Unknown", "Available". :vartype assessment_state: str or ~azure.mgmt.compute.v2022_03_01.models.PatchAssessmentState """ @@ -14724,14 +14690,13 @@ class VirtualMachineUpdate(UpdateResource): 2018-04-01. :vartype proximity_placement_group: ~azure.mgmt.compute.v2022_03_01.models.SubResource :ivar priority: Specifies the priority for the virtual machine. :code:`
`:code:`
`Minimum - api-version: 2019-03-01. Possible values include: "Regular", "Low", "Spot". + api-version: 2019-03-01. Known values are: "Regular", "Low", "Spot". :vartype priority: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachinePriorityTypes :ivar eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :vartype eviction_policy: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineEvictionPolicyTypes :ivar billing_profile: Specifies the billing related details of a Azure Spot virtual machine. @@ -14838,31 +14803,31 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - plan: Optional["Plan"] = None, - identity: Optional["VirtualMachineIdentity"] = None, + plan: Optional["_models.Plan"] = None, + identity: Optional["_models.VirtualMachineIdentity"] = None, zones: Optional[List[str]] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - additional_capabilities: Optional["AdditionalCapabilities"] = None, - os_profile: Optional["OSProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - security_profile: Optional["SecurityProfile"] = None, - diagnostics_profile: Optional["DiagnosticsProfile"] = None, - availability_set: Optional["SubResource"] = None, - virtual_machine_scale_set: Optional["SubResource"] = None, - proximity_placement_group: Optional["SubResource"] = None, - priority: Optional[Union[str, "VirtualMachinePriorityTypes"]] = None, - eviction_policy: Optional[Union[str, "VirtualMachineEvictionPolicyTypes"]] = None, - billing_profile: Optional["BillingProfile"] = None, - host: Optional["SubResource"] = None, - host_group: Optional["SubResource"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + additional_capabilities: Optional["_models.AdditionalCapabilities"] = None, + os_profile: Optional["_models.OSProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + diagnostics_profile: Optional["_models.DiagnosticsProfile"] = None, + availability_set: Optional["_models.SubResource"] = None, + virtual_machine_scale_set: Optional["_models.SubResource"] = None, + proximity_placement_group: Optional["_models.SubResource"] = None, + priority: Optional[Union[str, "_models.VirtualMachinePriorityTypes"]] = None, + eviction_policy: Optional[Union[str, "_models.VirtualMachineEvictionPolicyTypes"]] = None, + billing_profile: Optional["_models.BillingProfile"] = None, + host: Optional["_models.SubResource"] = None, + host_group: Optional["_models.SubResource"] = None, license_type: Optional[str] = None, extensions_time_budget: Optional[str] = None, platform_fault_domain: Optional[int] = None, - scheduled_events_profile: Optional["ScheduledEventsProfile"] = None, + scheduled_events_profile: Optional["_models.ScheduledEventsProfile"] = None, user_data: Optional[str] = None, - capacity_reservation: Optional["CapacityReservationProfile"] = None, - application_profile: Optional["ApplicationProfile"] = None, + capacity_reservation: Optional["_models.CapacityReservationProfile"] = None, + application_profile: Optional["_models.ApplicationProfile"] = None, **kwargs ): """ @@ -14924,15 +14889,14 @@ def __init__( 2018-04-01. :paramtype proximity_placement_group: ~azure.mgmt.compute.v2022_03_01.models.SubResource :keyword priority: Specifies the priority for the virtual machine. - :code:`
`:code:`
`Minimum api-version: 2019-03-01. Possible values include: "Regular", - "Low", "Spot". + :code:`
`:code:`
`Minimum api-version: 2019-03-01. Known values are: "Regular", "Low", + "Spot". :paramtype priority: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachinePriorityTypes :keyword eviction_policy: Specifies the eviction policy for the Azure Spot virtual machine and Azure Spot scale set. :code:`
`:code:`
`For Azure Spot virtual machines, both 'Deallocate' and 'Delete' are supported and the minimum api-version is 2019-03-01. :code:`
`:code:`
`For Azure Spot scale sets, both 'Deallocate' and 'Delete' are supported - and the minimum api-version is 2017-10-30-preview. Possible values include: "Deallocate", - "Delete". + and the minimum api-version is 2017-10-30-preview. Known values are: "Deallocate", "Delete". :paramtype eviction_policy: str or ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineEvictionPolicyTypes :keyword billing_profile: Specifies the billing related details of a Azure Spot virtual @@ -15022,8 +14986,8 @@ class VMDiskSecurityProfile(msrest.serialization.Model): :ivar security_encryption_type: Specifies the EncryptionType of the managed disk. :code:`
` It is set to DiskWithVMGuestState for encryption of the managed disk along with VMGuestState blob, and VMGuestStateOnly for encryption of just the VMGuestState blob. - :code:`
`:code:`
` NOTE: It can be set for only Confidential VMs. Possible values - include: "VMGuestStateOnly", "DiskWithVMGuestState". + :code:`
`:code:`
` NOTE: It can be set for only Confidential VMs. Known values are: + "VMGuestStateOnly", "DiskWithVMGuestState". :vartype security_encryption_type: str or ~azure.mgmt.compute.v2022_03_01.models.SecurityEncryptionTypes :ivar disk_encryption_set: Specifies the customer managed disk encryption set resource id for @@ -15041,16 +15005,16 @@ class VMDiskSecurityProfile(msrest.serialization.Model): def __init__( self, *, - security_encryption_type: Optional[Union[str, "SecurityEncryptionTypes"]] = None, - disk_encryption_set: Optional["DiskEncryptionSetParameters"] = None, + security_encryption_type: Optional[Union[str, "_models.SecurityEncryptionTypes"]] = None, + disk_encryption_set: Optional["_models.DiskEncryptionSetParameters"] = None, **kwargs ): """ :keyword security_encryption_type: Specifies the EncryptionType of the managed disk. :code:`
` It is set to DiskWithVMGuestState for encryption of the managed disk along with VMGuestState blob, and VMGuestStateOnly for encryption of just the VMGuestState blob. - :code:`
`:code:`
` NOTE: It can be set for only Confidential VMs. Possible values - include: "VMGuestStateOnly", "DiskWithVMGuestState". + :code:`
`:code:`
` NOTE: It can be set for only Confidential VMs. Known values are: + "VMGuestStateOnly", "DiskWithVMGuestState". :paramtype security_encryption_type: str or ~azure.mgmt.compute.v2022_03_01.models.SecurityEncryptionTypes :keyword disk_encryption_set: Specifies the customer managed disk encryption set resource id @@ -15158,7 +15122,7 @@ class VmImagesInEdgeZoneListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["VirtualMachineImageResource"]] = None, + value: Optional[List["_models.VirtualMachineImageResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -15301,9 +15265,9 @@ def __init__( provision_vm_agent: Optional[bool] = None, enable_automatic_updates: Optional[bool] = None, time_zone: Optional[str] = None, - additional_unattend_content: Optional[List["AdditionalUnattendContent"]] = None, - patch_settings: Optional["PatchSettings"] = None, - win_rm: Optional["WinRMConfiguration"] = None, + additional_unattend_content: Optional[List["_models.AdditionalUnattendContent"]] = None, + patch_settings: Optional["_models.PatchSettings"] = None, + win_rm: Optional["_models.WinRMConfiguration"] = None, **kwargs ): """ @@ -15372,7 +15336,7 @@ class WindowsParameters(msrest.serialization.Model): def __init__( self, *, - classifications_to_include: Optional[List[Union[str, "VMGuestPatchClassificationWindows"]]] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationWindows"]]] = None, kb_numbers_to_include: Optional[List[str]] = None, kb_numbers_to_exclude: Optional[List[str]] = None, exclude_kbs_requiring_reboot: Optional[bool] = None, @@ -15407,7 +15371,7 @@ class WindowsVMGuestPatchAutomaticByPlatformSettings(msrest.serialization.Model) """Specifies additional settings to be applied when patch mode AutomaticByPlatform is selected in Windows patch settings. :ivar reboot_setting: Specifies the reboot setting for all AutomaticByPlatform patch - installation operations. Possible values include: "Unknown", "IfRequired", "Never", "Always". + installation operations. Known values are: "Unknown", "IfRequired", "Never", "Always". :vartype reboot_setting: str or ~azure.mgmt.compute.v2022_03_01.models.WindowsVMGuestPatchAutomaticByPlatformRebootSetting """ @@ -15419,12 +15383,12 @@ class WindowsVMGuestPatchAutomaticByPlatformSettings(msrest.serialization.Model) def __init__( self, *, - reboot_setting: Optional[Union[str, "WindowsVMGuestPatchAutomaticByPlatformRebootSetting"]] = None, + reboot_setting: Optional[Union[str, "_models.WindowsVMGuestPatchAutomaticByPlatformRebootSetting"]] = None, **kwargs ): """ :keyword reboot_setting: Specifies the reboot setting for all AutomaticByPlatform patch - installation operations. Possible values include: "Unknown", "IfRequired", "Never", "Always". + installation operations. Known values are: "Unknown", "IfRequired", "Never", "Always". :paramtype reboot_setting: str or ~azure.mgmt.compute.v2022_03_01.models.WindowsVMGuestPatchAutomaticByPlatformRebootSetting """ @@ -15446,7 +15410,7 @@ class WinRMConfiguration(msrest.serialization.Model): def __init__( self, *, - listeners: Optional[List["WinRMListener"]] = None, + listeners: Optional[List["_models.WinRMListener"]] = None, **kwargs ): """ @@ -15461,7 +15425,7 @@ class WinRMListener(msrest.serialization.Model): """Describes Protocol and thumbprint of Windows Remote Management listener. :ivar protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :vartype protocol: str or ~azure.mgmt.compute.v2022_03_01.models.ProtocolTypes :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as @@ -15486,13 +15450,13 @@ class WinRMListener(msrest.serialization.Model): def __init__( self, *, - protocol: Optional[Union[str, "ProtocolTypes"]] = None, + protocol: Optional[Union[str, "_models.ProtocolTypes"]] = None, certificate_url: Optional[str] = None, **kwargs ): """ :keyword protocol: Specifies the protocol of WinRM listener. :code:`
`:code:`
` Possible - values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Possible values include: + values are: :code:`
`\ **http** :code:`
`:code:`
` **https**. Known values are: "Http", "Https". :paramtype protocol: str or ~azure.mgmt.compute.v2022_03_01.models.ProtocolTypes :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/__init__.py index 9e7600d93081..4d943f233924 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/__init__.py @@ -33,6 +33,9 @@ from ._virtual_machine_run_commands_operations import VirtualMachineRunCommandsOperations from ._virtual_machine_scale_set_vm_run_commands_operations import VirtualMachineScaleSetVMRunCommandsOperations +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', 'UsageOperations', @@ -61,3 +64,5 @@ 'VirtualMachineRunCommandsOperations', 'VirtualMachineScaleSetVMRunCommandsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_availability_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_availability_sets_operations.py index c4ec5c84272d..8950adede374 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_availability_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_availability_sets_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( availability_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailabilitySetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,9 +123,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -157,9 +160,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +177,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -193,9 +197,12 @@ def build_list_by_subscription_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets") path_format_arguments = { @@ -205,20 +212,18 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -228,9 +233,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets") # pylint: disable=line-too-long path_format_arguments = { @@ -241,18 +249,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -263,9 +269,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -277,51 +286,47 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AvailabilitySetsOperations(object): - """AvailabilitySetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class AvailabilitySetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`availability_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySet", + parameters: _models.AvailabilitySet, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Create or update an availability set. :param resource_group_name: The name of the resource group. @@ -335,14 +340,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySet') @@ -354,11 +362,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -384,9 +394,9 @@ def update( self, resource_group_name: str, availability_set_name: str, - parameters: "_models.AvailabilitySetUpdate", + parameters: _models.AvailabilitySetUpdate, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Update an availability set. :param resource_group_name: The name of the resource group. @@ -400,14 +410,17 @@ def update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] _json = self._serialize.body(parameters, 'AvailabilitySetUpdate') @@ -419,11 +432,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -462,13 +477,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -477,11 +495,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -504,7 +524,7 @@ def get( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> "_models.AvailabilitySet": + ) -> _models.AvailabilitySet: """Retrieves information about an availability set. :param resource_group_name: The name of the resource group. @@ -516,13 +536,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.AvailabilitySet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySet] request = build_get_request( @@ -531,11 +554,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -561,7 +586,7 @@ def list_by_subscription( self, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a subscription. :param expand: The expand expression to apply to the operation. Allowed values are @@ -574,13 +599,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -589,9 +617,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -600,9 +630,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -640,7 +672,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.AvailabilitySetListResult"]: + ) -> Iterable[_models.AvailabilitySetListResult]: """Lists all availability sets in a resource group. :param resource_group_name: The name of the resource group. @@ -652,13 +684,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.AvailabilitySetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailabilitySetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilitySetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -667,9 +702,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -678,9 +715,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -719,7 +758,7 @@ def list_available_sizes( resource_group_name: str, availability_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes that can be used to create a new virtual machine in an existing availability set. @@ -734,13 +773,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -750,9 +792,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -762,9 +806,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_capacity_reservation_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_capacity_reservation_groups_operations.py index 9fdbbc3fee2d..cf2c742633fd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_capacity_reservation_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_capacity_reservation_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( capacity_reservation_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservationGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( capacity_reservation_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservationGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,9 +123,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_get_request( expand: Optional[Union[str, "_models.CapacityReservationGroupInstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,20 +179,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_by_resource_group_request( expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -211,20 +218,18 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -235,9 +240,12 @@ def build_list_by_subscription_request( expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/capacityReservationGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -247,53 +255,49 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) -class CapacityReservationGroupsOperations(object): - """CapacityReservationGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CapacityReservationGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`capacity_reservation_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroup", + parameters: _models.CapacityReservationGroup, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to create or update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. Please refer to https://aka.ms/CapacityReservation for more details. @@ -309,14 +313,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroup') @@ -328,11 +335,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -362,9 +371,9 @@ def update( self, resource_group_name: str, capacity_reservation_group_name: str, - parameters: "_models.CapacityReservationGroupUpdate", + parameters: _models.CapacityReservationGroupUpdate, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation to update a capacity reservation group. When updating a capacity reservation group, only tags may be modified. @@ -379,14 +388,17 @@ def update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] _json = self._serialize.body(parameters, 'CapacityReservationGroupUpdate') @@ -398,11 +410,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -444,13 +458,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -459,11 +476,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -487,7 +506,7 @@ def get( capacity_reservation_group_name: str, expand: Optional[Union[str, "_models.CapacityReservationGroupInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservationGroup": + ) -> _models.CapacityReservationGroup: """The operation that retrieves information about a capacity reservation group. :param resource_group_name: The name of the resource group. @@ -505,13 +524,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.CapacityReservationGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroup] request = build_get_request( @@ -521,11 +543,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -552,7 +576,7 @@ def list_by_resource_group( resource_group_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> Iterable["_models.CapacityReservationGroupListResult"]: + ) -> Iterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the specified resource group. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -570,13 +594,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -586,9 +613,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, 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: @@ -598,9 +627,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -638,7 +669,7 @@ def list_by_subscription( self, expand: Optional[Union[str, "_models.ExpandTypesForGetCapacityReservationGroups"]] = None, **kwargs: Any - ) -> Iterable["_models.CapacityReservationGroupListResult"]: + ) -> Iterable[_models.CapacityReservationGroupListResult]: """Lists all of the capacity reservation groups in the subscription. Use the nextLink property in the response to get the next page of capacity reservation groups. @@ -654,13 +685,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.CapacityReservationGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -669,9 +703,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -680,9 +716,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_capacity_reservations_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_capacity_reservations_operations.py index 82211a75d562..fbe8436cae07 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_capacity_reservations_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_capacity_reservations_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( capacity_reservation_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservation] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( capacity_reservation_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.CapacityReservationUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -168,9 +171,12 @@ def build_get_request( expand: Optional[Union[str, "_models.CapacityReservationInstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}") # pylint: disable=line-too-long path_format_arguments = { @@ -183,20 +189,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -207,9 +211,12 @@ def build_list_by_capacity_reservation_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations") # pylint: disable=line-too-long path_format_arguments = { @@ -221,59 +228,58 @@ def build_list_by_capacity_reservation_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class CapacityReservationsOperations(object): - """CapacityReservationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CapacityReservationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`capacity_reservations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> "_models.CapacityReservation": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] + ) -> _models.CapacityReservation: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] _json = self._serialize.body(parameters, 'CapacityReservation') @@ -286,11 +292,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -321,9 +329,9 @@ def begin_create_or_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservation", + parameters: _models.CapacityReservation, **kwargs: Any - ) -> LROPoller["_models.CapacityReservation"]: + ) -> LROPoller[_models.CapacityReservation]: """The operation to create or update a capacity reservation. Please note some properties can be set only during capacity reservation creation. Please refer to https://aka.ms/CapacityReservation for more details. @@ -350,17 +358,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -368,20 +379,27 @@ def begin_create_or_update( 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('CapacityReservation', 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( @@ -399,17 +417,20 @@ def _update_initial( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> Optional["_models.CapacityReservation"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CapacityReservation"]] + ) -> Optional[_models.CapacityReservation]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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.CapacityReservation]] _json = self._serialize.body(parameters, 'CapacityReservationUpdate') @@ -422,11 +443,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -455,9 +478,9 @@ def begin_update( resource_group_name: str, capacity_reservation_group_name: str, capacity_reservation_name: str, - parameters: "_models.CapacityReservationUpdate", + parameters: _models.CapacityReservationUpdate, **kwargs: Any - ) -> LROPoller["_models.CapacityReservation"]: + ) -> LROPoller[_models.CapacityReservation]: """The operation to update a capacity reservation. :param resource_group_name: The name of the resource group. @@ -482,17 +505,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.CapacityReservation] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, @@ -500,20 +526,27 @@ def begin_update( 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('CapacityReservation', 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( @@ -533,13 +566,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements capacity_reservation_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -549,11 +585,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -600,21 +638,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, capacity_reservation_group_name=capacity_reservation_group_name, capacity_reservation_name=capacity_reservation_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -624,8 +667,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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,7 +695,7 @@ def get( capacity_reservation_name: str, expand: Optional[Union[str, "_models.CapacityReservationInstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.CapacityReservation": + ) -> _models.CapacityReservation: """The operation that retrieves information about the capacity reservation. :param resource_group_name: The name of the resource group. @@ -665,13 +714,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.CapacityReservation :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservation"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservation] request = build_get_request( @@ -682,11 +734,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -713,7 +767,7 @@ def list_by_capacity_reservation_group( resource_group_name: str, capacity_reservation_group_name: str, **kwargs: Any - ) -> Iterable["_models.CapacityReservationListResult"]: + ) -> Iterable[_models.CapacityReservationListResult]: """Lists all of the capacity reservations in the specified capacity reservation group. Use the nextLink property in the response to get the next page of capacity reservations. @@ -728,13 +782,16 @@ def list_by_capacity_reservation_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.CapacityReservationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CapacityReservationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapacityReservationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -744,9 +801,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_capacity_reservation_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: @@ -756,9 +815,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_dedicated_host_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_dedicated_host_groups_operations.py index 18a4996f0163..1edaf490a983 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_dedicated_host_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_dedicated_host_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( host_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,9 +123,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,20 +179,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -196,9 +200,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -209,18 +216,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -229,9 +234,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups") path_format_arguments = { @@ -241,51 +249,47 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostGroupsOperations(object): - """DedicatedHostGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`dedicated_host_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroup", + parameters: _models.DedicatedHostGroup, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596). @@ -301,14 +305,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroup') @@ -320,11 +327,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -354,9 +363,9 @@ def update( self, resource_group_name: str, host_group_name: str, - parameters: "_models.DedicatedHostGroupUpdate", + parameters: _models.DedicatedHostGroupUpdate, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Update an dedicated host group. :param resource_group_name: The name of the resource group. @@ -370,14 +379,17 @@ def update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] _json = self._serialize.body(parameters, 'DedicatedHostGroupUpdate') @@ -389,11 +401,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,13 +446,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -447,11 +464,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -475,7 +494,7 @@ def get( host_group_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHostGroup": + ) -> _models.DedicatedHostGroup: """Retrieves information about a dedicated host group. :param resource_group_name: The name of the resource group. @@ -491,13 +510,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.DedicatedHostGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroup] request = build_get_request( @@ -507,11 +529,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -537,7 +561,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -550,13 +574,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -565,9 +592,11 @@ def prepare_request(next_link=None): 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: @@ -576,9 +605,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -615,7 +646,7 @@ def get_next(next_link=None): def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.DedicatedHostGroupListResult"]: + ) -> Iterable[_models.DedicatedHostGroupListResult]: """Lists all of the dedicated host groups in the subscription. Use the nextLink property in the response to get the next page of dedicated host groups. @@ -626,13 +657,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.DedicatedHostGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -640,9 +674,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -650,9 +686,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_dedicated_hosts_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_dedicated_hosts_operations.py index d0d6206aa998..984adb06b3cf 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_dedicated_hosts_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_dedicated_hosts_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHost] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( host_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DedicatedHostUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -168,9 +171,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}") # pylint: disable=line-too-long path_format_arguments = { @@ -183,20 +189,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -207,9 +211,12 @@ def build_list_by_host_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts") # pylint: disable=line-too-long path_format_arguments = { @@ -221,18 +228,16 @@ def build_list_by_host_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -244,9 +249,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -259,59 +267,58 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class DedicatedHostsOperations(object): - """DedicatedHostsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DedicatedHostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`dedicated_hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHost') @@ -324,11 +331,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -359,9 +368,9 @@ def begin_create_or_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHost", + parameters: _models.DedicatedHost, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Create or update a dedicated host . :param resource_group_name: The name of the resource group. @@ -385,17 +394,20 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -403,20 +415,27 @@ def begin_create_or_update( 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('DedicatedHost', 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( @@ -434,17 +453,20 @@ def _update_initial( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> "_models.DedicatedHost": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] + ) -> _models.DedicatedHost: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] _json = self._serialize.body(parameters, 'DedicatedHostUpdate') @@ -457,11 +479,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -488,9 +512,9 @@ def begin_update( resource_group_name: str, host_group_name: str, host_name: str, - parameters: "_models.DedicatedHostUpdate", + parameters: _models.DedicatedHostUpdate, **kwargs: Any - ) -> LROPoller["_models.DedicatedHost"]: + ) -> LROPoller[_models.DedicatedHost]: """Update an dedicated host . :param resource_group_name: The name of the resource group. @@ -514,17 +538,20 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.DedicatedHost] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, @@ -532,20 +559,27 @@ def begin_update( 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('DedicatedHost', 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( @@ -565,13 +599,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements host_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -581,11 +618,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -630,21 +669,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -654,8 +698,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -676,7 +726,7 @@ def get( host_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.DedicatedHost": + ) -> _models.DedicatedHost: """Retrieves information about a dedicated host. :param resource_group_name: The name of the resource group. @@ -694,13 +744,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.DedicatedHost :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHost"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHost] request = build_get_request( @@ -711,11 +764,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -742,7 +797,7 @@ def list_by_host_group( resource_group_name: str, host_group_name: str, **kwargs: Any - ) -> Iterable["_models.DedicatedHostListResult"]: + ) -> Iterable[_models.DedicatedHostListResult]: """Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in the response to get the next page of dedicated hosts. @@ -757,13 +812,16 @@ def list_by_host_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.DedicatedHostListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DedicatedHostListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DedicatedHostListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -773,9 +831,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_host_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: @@ -785,9 +845,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -827,13 +889,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements host_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -843,11 +908,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -896,21 +963,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, host_group_name=host_group_name, host_name=host_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -920,8 +992,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_images_operations.py index 08ed41ab5310..5dd9dca30da5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_images_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.Image] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( image_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImageUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -161,9 +164,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images") # pylint: disable=line-too-long path_format_arguments = { @@ -211,18 +218,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +236,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images") path_format_arguments = { @@ -243,58 +251,57 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ImagesOperations(object): - """ImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'Image') @@ -306,11 +313,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -340,9 +349,9 @@ def begin_create_or_update( self, resource_group_name: str, image_name: str, - parameters: "_models.Image", + parameters: _models.Image, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Create or update an image. :param resource_group_name: The name of the resource group. @@ -363,37 +372,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -410,17 +429,20 @@ def _update_initial( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> "_models.Image": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] + ) -> _models.Image: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] _json = self._serialize.body(parameters, 'ImageUpdate') @@ -432,11 +454,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -466,9 +490,9 @@ def begin_update( self, resource_group_name: str, image_name: str, - parameters: "_models.ImageUpdate", + parameters: _models.ImageUpdate, **kwargs: Any - ) -> LROPoller["_models.Image"]: + ) -> LROPoller[_models.Image]: """Update an image. :param resource_group_name: The name of the resource group. @@ -489,37 +513,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.Image] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_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('Image', 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( @@ -538,13 +572,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements image_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -553,11 +590,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -599,20 +638,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, image_name=image_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -622,8 +666,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -643,7 +693,7 @@ def get( image_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.Image": + ) -> _models.Image: """Gets an image. :param resource_group_name: The name of the resource group. @@ -657,13 +707,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.Image :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Image"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Image] request = build_get_request( @@ -673,11 +726,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -703,7 +758,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of images under a resource group. :param resource_group_name: The name of the resource group. @@ -713,13 +768,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -728,9 +786,11 @@ def prepare_request(next_link=None): 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: @@ -739,9 +799,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -778,7 +840,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.ImageListResult"]: + ) -> Iterable[_models.ImageListResult]: """Gets the list of Images in the subscription. Use nextLink property in the response to get the next page of Images. Do this till nextLink is null to fetch all the Images. @@ -787,13 +849,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.ImageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImageListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImageListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -801,9 +866,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -811,9 +878,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_log_analytics_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_log_analytics_operations.py index 5fc63e7ffd18..34e0f35a4ecd 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_log_analytics_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_log_analytics_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +32,17 @@ def build_export_request_rate_by_interval_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RequestRateByIntervalInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval") # pylint: disable=line-too-long path_format_arguments = { @@ -50,20 +53,18 @@ def build_export_request_rate_by_interval_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_export_throttled_requests_request_initial( location: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ThrottledRequestsInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -92,61 +96,60 @@ def build_export_throttled_requests_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class LogAnalyticsOperations(object): - """LogAnalyticsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LogAnalyticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`log_analytics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _export_request_rate_by_interval_initial( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'RequestRateByIntervalInput') @@ -157,11 +160,13 @@ def _export_request_rate_by_interval_initial( content_type=content_type, json=_json, template_url=self._export_request_rate_by_interval_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -188,9 +193,9 @@ def _export_request_rate_by_interval_initial( def begin_export_request_rate_by_interval( self, location: str, - parameters: "_models.RequestRateByIntervalInput", + parameters: _models.RequestRateByIntervalInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show Api requests made by this subscription in the given time window to show throttling activities. @@ -212,36 +217,46 @@ def begin_export_request_rate_by_interval( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_request_rate_by_interval_initial( + raw_result = self._export_request_rate_by_interval_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -257,17 +272,20 @@ def get_long_running_output(pipeline_response): def _export_throttled_requests_initial( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> Optional["_models.LogAnalyticsOperationResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.LogAnalyticsOperationResult"]] + ) -> Optional[_models.LogAnalyticsOperationResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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.LogAnalyticsOperationResult]] _json = self._serialize.body(parameters, 'ThrottledRequestsInput') @@ -278,11 +296,13 @@ def _export_throttled_requests_initial( content_type=content_type, json=_json, template_url=self._export_throttled_requests_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -309,9 +329,9 @@ def _export_throttled_requests_initial( def begin_export_throttled_requests( self, location: str, - parameters: "_models.ThrottledRequestsInput", + parameters: _models.ThrottledRequestsInput, **kwargs: Any - ) -> LROPoller["_models.LogAnalyticsOperationResult"]: + ) -> LROPoller[_models.LogAnalyticsOperationResult]: """Export logs that show total throttled Api requests for this subscription in the given time window. @@ -333,36 +353,46 @@ def begin_export_throttled_requests( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.LogAnalyticsOperationResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.LogAnalyticsOperationResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.LogAnalyticsOperationResult"] 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._export_throttled_requests_initial( + raw_result = self._export_throttled_requests_initial( # type: ignore location=location, 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('LogAnalyticsOperationResult', 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': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_operations.py index 48353c766851..9c32364bad8e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_operations.py @@ -16,6 +16,7 @@ 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 @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Compute/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, + 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'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.ComputeOperationListResult"]: + ) -> Iterable[_models.ComputeOperationListResult]: """Gets a list of compute operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -87,31 +87,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.ComputeOperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ComputeOperationListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ComputeOperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_proximity_placement_groups_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_proximity_placement_groups_operations.py index 8a1551448e0d..e8f8815b9fa8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_proximity_placement_groups_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_proximity_placement_groups_operations.py @@ -16,12 +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 .. 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,14 +32,17 @@ def build_create_or_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroup] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -76,14 +77,17 @@ def build_update_request( proximity_placement_group_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ProximityPlacementGroupUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -95,20 +99,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -121,9 +123,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_get_request( include_colocation_status: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,20 +179,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if include_colocation_status is not None: - _query_parameters['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['includeColocationStatus'] = _SERIALIZER.query("include_colocation_status", include_colocation_status, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -195,9 +199,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups") path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -228,9 +233,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups") # pylint: disable=line-too-long path_format_arguments = { @@ -241,51 +249,47 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ProximityPlacementGroupsOperations(object): - """ProximityPlacementGroupsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ProximityPlacementGroupsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`proximity_placement_groups` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroup", + parameters: _models.ProximityPlacementGroup, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Create or update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -299,14 +303,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroup') @@ -318,11 +325,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -352,9 +361,9 @@ def update( self, resource_group_name: str, proximity_placement_group_name: str, - parameters: "_models.ProximityPlacementGroupUpdate", + parameters: _models.ProximityPlacementGroupUpdate, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Update a proximity placement group. :param resource_group_name: The name of the resource group. @@ -368,14 +377,17 @@ def update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] _json = self._serialize.body(parameters, 'ProximityPlacementGroupUpdate') @@ -387,11 +399,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -430,13 +444,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -445,11 +462,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -473,7 +492,7 @@ def get( proximity_placement_group_name: str, include_colocation_status: Optional[str] = None, **kwargs: Any - ) -> "_models.ProximityPlacementGroup": + ) -> _models.ProximityPlacementGroup: """Retrieves information about a proximity placement group . :param resource_group_name: The name of the resource group. @@ -488,13 +507,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.ProximityPlacementGroup :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroup"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroup] request = build_get_request( @@ -504,11 +526,13 @@ def get( api_version=api_version, include_colocation_status=include_colocation_status, 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -533,7 +557,7 @@ def get( def list_by_subscription( self, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -543,13 +567,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +584,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -567,9 +596,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -607,7 +638,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.ProximityPlacementGroupListResult"]: + ) -> Iterable[_models.ProximityPlacementGroupListResult]: """Lists all proximity placement groups in a resource group. :param resource_group_name: The name of the resource group. @@ -619,13 +650,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.ProximityPlacementGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ProximityPlacementGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProximityPlacementGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -634,9 +668,11 @@ def prepare_request(next_link=None): 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: @@ -645,9 +681,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_restore_point_collections_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_restore_point_collections_operations.py index 69898ec47fb5..52669ef7d0ff 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_restore_point_collections_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_restore_point_collections_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request( resource_group_name: str, restore_point_collection_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePointCollection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request( resource_group_name: str, restore_point_collection_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePointCollectionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_delete_request_initial( restore_point_collection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -161,9 +164,12 @@ def build_get_request( expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -198,9 +202,12 @@ def build_list_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections") # pylint: disable=line-too-long path_format_arguments = { @@ -211,18 +218,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +236,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/restorePointCollections") path_format_arguments = { @@ -243,51 +251,47 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class RestorePointCollectionsOperations(object): - """RestorePointCollectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RestorePointCollectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`restore_point_collections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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_or_update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollection", + parameters: _models.RestorePointCollection, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to create or update the restore point collection. Please refer to https://aka.ms/RestorePoints for more details. When updating a restore point collection, only tags may be modified. @@ -304,14 +308,17 @@ def create_or_update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollection') @@ -323,11 +330,13 @@ def create_or_update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -357,9 +366,9 @@ def update( self, resource_group_name: str, restore_point_collection_name: str, - parameters: "_models.RestorePointCollectionUpdate", + parameters: _models.RestorePointCollectionUpdate, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to update the restore point collection. :param resource_group_name: The name of the resource group. @@ -373,14 +382,17 @@ def update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] _json = self._serialize.body(parameters, 'RestorePointCollectionUpdate') @@ -392,11 +404,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -423,13 +437,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -438,11 +455,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_collection_name=restore_point_collection_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -485,20 +504,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -508,8 +532,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -529,7 +559,7 @@ def get( restore_point_collection_name: str, expand: Optional[Union[str, "_models.RestorePointCollectionExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePointCollection": + ) -> _models.RestorePointCollection: """The operation to get the restore point collection. :param resource_group_name: The name of the resource group. @@ -544,13 +574,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RestorePointCollection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollection] request = build_get_request( @@ -560,11 +593,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -590,7 +625,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.RestorePointCollectionListResult"]: + ) -> Iterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in a resource group. :param resource_group_name: The name of the resource group. @@ -602,13 +637,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -617,9 +655,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -628,9 +668,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -667,7 +709,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.RestorePointCollectionListResult"]: + ) -> Iterable[_models.RestorePointCollectionListResult]: """Gets the list of restore point collections in the subscription. Use nextLink property in the response to get the next page of restore point collections. Do this till nextLink is not null to fetch all the restore point collections. @@ -679,13 +721,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.RestorePointCollectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePointCollectionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePointCollectionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -693,9 +738,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -703,9 +750,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_restore_points_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_restore_points_operations.py index 1283d4f5f484..d2fe8b2fed7b 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_restore_points_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_restore_points_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_request_initial( restore_point_collection_name: str, restore_point_name: str, *, - json: JSONType = None, + json: Optional[_models.RestorePoint] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,9 +82,12 @@ def build_delete_request_initial( restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -96,18 +100,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -121,9 +123,12 @@ def build_get_request( expand: Optional[Union[str, "_models.RestorePointExpandOptions"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{restorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -136,61 +141,60 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class RestorePointsOperations(object): - """RestorePointsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class RestorePointsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`restore_points` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_initial( self, resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> "_models.RestorePoint": - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] + ) -> _models.RestorePoint: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] _json = self._serialize.body(parameters, 'RestorePoint') @@ -203,11 +207,13 @@ def _create_initial( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -234,9 +240,9 @@ def begin_create( resource_group_name: str, restore_point_collection_name: str, restore_point_name: str, - parameters: "_models.RestorePoint", + parameters: _models.RestorePoint, **kwargs: Any - ) -> LROPoller["_models.RestorePoint"]: + ) -> LROPoller[_models.RestorePoint]: """The operation to create the restore point. Updating properties of an existing restore point is not allowed. @@ -261,17 +267,20 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.RestorePoint] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] 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, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, @@ -279,20 +288,27 @@ def begin_create( 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('RestorePoint', 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( @@ -312,13 +328,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -328,11 +347,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements restore_point_name=restore_point_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -377,21 +398,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, restore_point_name=restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -401,8 +427,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -423,7 +455,7 @@ def get( restore_point_name: str, expand: Optional[Union[str, "_models.RestorePointExpandOptions"]] = None, **kwargs: Any - ) -> "_models.RestorePoint": + ) -> _models.RestorePoint: """The operation to get the restore point. :param resource_group_name: The name of the resource group. @@ -440,13 +472,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RestorePoint] request = build_get_request( @@ -457,11 +492,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_ssh_public_keys_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_ssh_public_keys_operations.py index 15c4d9633be6..896e044c100c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_ssh_public_keys_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_ssh_public_keys_operations.py @@ -16,12 +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 .. 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,9 +31,12 @@ def build_list_by_subscription_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/sshPublicKeys") path_format_arguments = { @@ -43,18 +46,16 @@ def build_list_by_subscription_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -64,9 +65,12 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys") # pylint: disable=line-too-long path_format_arguments = { @@ -77,18 +81,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -98,14 +100,17 @@ def build_create_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -117,20 +122,18 @@ def build_create_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -142,14 +145,17 @@ def build_update_request( ssh_public_key_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.SshPublicKeyUpdateResource] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -161,20 +167,18 @@ def build_update_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -187,9 +191,12 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +208,16 @@ def build_delete_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -223,9 +228,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}") # pylint: disable=line-too-long path_format_arguments = { @@ -237,18 +245,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -259,9 +265,12 @@ def build_generate_key_pair_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}/generateKeyPair") # pylint: disable=line-too-long path_format_arguments = { @@ -273,48 +282,44 @@ def build_generate_key_pair_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class SshPublicKeysOperations(object): - """SshPublicKeysOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SshPublicKeysOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`ssh_public_keys` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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_subscription( self, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the subscription. Use the nextLink property in the response to get the next page of SSH public keys. @@ -325,13 +330,16 @@ def list_by_subscription( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -339,9 +347,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_subscription.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -349,9 +359,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -389,7 +401,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SshPublicKeysGroupListResult"]: + ) -> Iterable[_models.SshPublicKeysGroupListResult]: """Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the response to get the next page of SSH public keys. @@ -402,13 +414,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.SshPublicKeysGroupListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeysGroupListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeysGroupListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -417,9 +432,11 @@ def prepare_request(next_link=None): 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: @@ -428,9 +445,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -468,9 +487,9 @@ def create( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyResource", + parameters: _models.SshPublicKeyResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Creates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -484,14 +503,17 @@ def create( :rtype: ~azure.mgmt.compute.v2022_03_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyResource') @@ -503,11 +525,13 @@ def create( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -537,9 +561,9 @@ def update( self, resource_group_name: str, ssh_public_key_name: str, - parameters: "_models.SshPublicKeyUpdateResource", + parameters: _models.SshPublicKeyUpdateResource, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Updates a new SSH public key resource. :param resource_group_name: The name of the resource group. @@ -553,14 +577,17 @@ def update( :rtype: ~azure.mgmt.compute.v2022_03_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] _json = self._serialize.body(parameters, 'SshPublicKeyUpdateResource') @@ -572,11 +599,13 @@ def update( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -615,13 +644,16 @@ def delete( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -630,11 +662,13 @@ def delete( # pylint: disable=inconsistent-return-statements 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -657,7 +691,7 @@ def get( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyResource": + ) -> _models.SshPublicKeyResource: """Retrieves information about an SSH public key. :param resource_group_name: The name of the resource group. @@ -669,13 +703,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.SshPublicKeyResource :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyResource"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyResource] request = build_get_request( @@ -684,11 +721,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -715,7 +754,7 @@ def generate_key_pair( resource_group_name: str, ssh_public_key_name: str, **kwargs: Any - ) -> "_models.SshPublicKeyGenerateKeyPairResult": + ) -> _models.SshPublicKeyGenerateKeyPairResult: """Generates and returns a public/private key pair and populates the SSH public key resource with the public key. The length of the key will be 3072 bits. This operation can only be performed once per SSH public key resource. @@ -729,13 +768,16 @@ def generate_key_pair( :rtype: ~azure.mgmt.compute.v2022_03_01.models.SshPublicKeyGenerateKeyPairResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SshPublicKeyGenerateKeyPairResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SshPublicKeyGenerateKeyPairResult] request = build_generate_key_pair_request( @@ -744,11 +786,13 @@ def generate_key_pair( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generate_key_pair.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_usage_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_usage_operations.py index 9867ca50cee6..0494d86b4d0c 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_usage_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_usage_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'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, location: str, **kwargs: Any - ) -> Iterable["_models.ListUsagesResult"]: + ) -> Iterable[_models.ListUsagesResult]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. @@ -97,13 +97,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUsagesResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUsagesResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -112,9 +115,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -123,9 +128,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_extension_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_extension_images_operations.py index 1534c73f1c8b..1a13c2d43999 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_extension_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_extension_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -33,9 +34,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -49,18 +53,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -71,9 +73,12 @@ def build_list_types_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types") # pylint: disable=line-too-long path_format_arguments = { @@ -85,18 +90,16 @@ def build_list_types_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -112,9 +115,12 @@ def build_list_versions_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -127,48 +133,44 @@ def build_list_versions_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionImagesOperations(object): - """VirtualMachineExtensionImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_extension_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -178,7 +180,7 @@ def get( type: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineExtensionImage": + ) -> _models.VirtualMachineExtensionImage: """Gets a virtual machine extension image. :param location: The name of a supported Azure region. @@ -194,13 +196,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtensionImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionImage] request = build_get_request( @@ -211,11 +216,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,7 +249,7 @@ def list_types( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image types. :param location: The name of a supported Azure region. @@ -254,13 +261,16 @@ def list_types( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_types_request( @@ -269,11 +279,13 @@ def list_types( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_types.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -304,7 +316,7 @@ def list_versions( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineExtensionImage"]: + ) -> List[_models.VirtualMachineExtensionImage]: """Gets a list of virtual machine extension image versions. :param location: The name of a supported Azure region. @@ -324,13 +336,16 @@ def list_versions( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtensionImage] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineExtensionImage"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineExtensionImage]] request = build_list_versions_request( @@ -343,11 +358,13 @@ def list_versions( top=top, orderby=orderby, template_url=self.list_versions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_extensions_operations.py index 75bb957d1e8e..c6064a0654f9 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -54,20 +57,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -80,14 +81,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -100,20 +104,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,9 +129,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -142,18 +147,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -167,9 +170,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -182,20 +188,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -208,9 +212,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -222,61 +229,60 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineExtensionsOperations(object): - """VirtualMachineExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtension') @@ -289,11 +295,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -324,9 +332,9 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtension", + extension_parameters: _models.VirtualMachineExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to create or update the extension. :param resource_group_name: The name of the resource group. @@ -353,17 +361,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -371,20 +382,27 @@ def begin_create_or_update( 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('VirtualMachineExtension', 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( @@ -402,17 +420,20 @@ def _update_initial( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] + ) -> _models.VirtualMachineExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineExtensionUpdate') @@ -425,11 +446,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -456,9 +479,9 @@ def begin_update( resource_group_name: str, vm_name: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineExtensionUpdate", + extension_parameters: _models.VirtualMachineExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineExtension"]: + ) -> LROPoller[_models.VirtualMachineExtension]: """The operation to update the extension. :param resource_group_name: The name of the resource group. @@ -485,17 +508,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, @@ -503,20 +529,27 @@ def begin_update( 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('VirtualMachineExtension', 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( @@ -536,13 +569,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -552,11 +588,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -601,21 +639,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -625,8 +668,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -647,7 +696,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtension": + ) -> _models.VirtualMachineExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -663,13 +712,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtension] request = build_get_request( @@ -680,11 +732,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -712,7 +766,7 @@ def list( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineExtensionsListResult": + ) -> _models.VirtualMachineExtensionsListResult: """The operation to get all extensions of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -726,13 +780,16 @@ def list( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineExtensionsListResult] request = build_list_request( @@ -742,11 +799,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_images_edge_zone_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_images_edge_zone_operations.py index 2280301d8ff4..ee404412015e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_images_edge_zone_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_images_edge_zone_operations.py @@ -15,6 +15,7 @@ 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 @@ -35,9 +36,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,18 +57,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -82,9 +84,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -99,24 +104,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -128,9 +131,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +149,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -165,9 +169,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -179,18 +186,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -203,9 +208,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -219,42 +227,38 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesEdgeZoneOperations(object): - """VirtualMachineImagesEdgeZoneOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesEdgeZoneOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_images_edge_zone` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -266,7 +270,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image in an edge zone. :param location: The name of a supported Azure region. @@ -286,13 +290,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -305,11 +312,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -342,7 +351,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, edge zone, publisher, offer, and SKU. @@ -369,13 +378,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -390,11 +402,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -422,7 +436,7 @@ def list_offers( edge_zone: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location, edge zone and publisher. @@ -437,13 +451,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -453,11 +470,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -484,7 +503,7 @@ def list_publishers( location: str, edge_zone: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location and edge zone. :param location: The name of a supported Azure region. @@ -496,13 +515,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -511,11 +533,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -544,7 +568,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, edge zone, publisher, and offer. @@ -561,13 +585,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -578,11 +605,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_images_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_images_operations.py index d434614f0db5..3a91cd2a1214 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_images_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_images_operations.py @@ -15,6 +15,7 @@ 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 @@ -34,9 +35,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +55,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -79,9 +81,12 @@ def build_list_request( orderby: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions") # pylint: disable=line-too-long path_format_arguments = { @@ -95,24 +100,22 @@ def build_list_request( _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') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params['$top'] = _SERIALIZER.query("top", top, 'int') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -123,9 +126,12 @@ def build_list_offers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +143,16 @@ def build_list_offers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -158,9 +162,12 @@ def build_list_publishers_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers") # pylint: disable=line-too-long path_format_arguments = { @@ -171,18 +178,16 @@ def build_list_publishers_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +199,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -209,18 +217,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -231,9 +237,12 @@ def build_list_by_edge_zone_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/edgeZones/{edgeZone}/vmimages") # pylint: disable=line-too-long path_format_arguments = { @@ -245,42 +254,38 @@ def build_list_by_edge_zone_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineImagesOperations(object): - """VirtualMachineImagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineImagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_images` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -291,7 +296,7 @@ def get( skus: str, version: str, **kwargs: Any - ) -> "_models.VirtualMachineImage": + ) -> _models.VirtualMachineImage: """Gets a virtual machine image. :param location: The name of a supported Azure region. @@ -309,13 +314,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImage :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineImage"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineImage] request = build_get_request( @@ -327,11 +335,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -363,7 +373,7 @@ def list( top: Optional[int] = None, orderby: Optional[str] = None, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU. @@ -386,13 +396,16 @@ def list( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_request( @@ -406,11 +419,13 @@ def list( top=top, orderby=orderby, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -437,7 +452,7 @@ def list_offers( location: str, publisher_name: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image offers for the specified location and publisher. :param location: The name of a supported Azure region. @@ -449,13 +464,16 @@ def list_offers( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_offers_request( @@ -464,11 +482,13 @@ def list_offers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_offers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -494,7 +514,7 @@ def list_publishers( self, location: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image publishers for the specified Azure location. :param location: The name of a supported Azure region. @@ -504,13 +524,16 @@ def list_publishers( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_publishers_request( @@ -518,11 +541,13 @@ def list_publishers( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_publishers.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -550,7 +575,7 @@ def list_skus( publisher_name: str, offer: str, **kwargs: Any - ) -> List["_models.VirtualMachineImageResource"]: + ) -> List[_models.VirtualMachineImageResource]: """Gets a list of virtual machine image SKUs for the specified location, publisher, and offer. :param location: The name of a supported Azure region. @@ -564,13 +589,16 @@ def list_skus( :rtype: list[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineImageResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.VirtualMachineImageResource"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.VirtualMachineImageResource]] request = build_list_skus_request( @@ -580,11 +608,13 @@ def list_skus( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -611,7 +641,7 @@ def list_by_edge_zone( location: str, edge_zone: str, **kwargs: Any - ) -> "_models.VmImagesInEdgeZoneListResult": + ) -> _models.VmImagesInEdgeZoneListResult: """Gets a list of all virtual machine image versions for the specified edge zone. :param location: The name of a supported Azure region. @@ -623,13 +653,16 @@ def list_by_edge_zone( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VmImagesInEdgeZoneListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VmImagesInEdgeZoneListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VmImagesInEdgeZoneListResult] request = build_list_by_edge_zone_request( @@ -638,11 +671,13 @@ def list_by_edge_zone( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_by_edge_zone.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_run_commands_operations.py index d05abc7a3c23..4f9e46a030b6 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -69,9 +70,12 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}") # pylint: disable=line-too-long path_format_arguments = { @@ -83,18 +87,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -105,14 +107,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -125,20 +130,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -151,14 +154,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -171,20 +177,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -198,9 +202,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -213,18 +220,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -238,9 +243,12 @@ def build_get_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -253,20 +261,18 @@ def build_get_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -279,9 +285,12 @@ def build_list_by_virtual_machine_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -293,51 +302,47 @@ def build_list_by_virtual_machine_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineRunCommandsOperations(object): - """VirtualMachineRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.RunCommandListResult"]: + ) -> Iterable[_models.RunCommandListResult]: """Lists all available run commands for a subscription in a location. :param location: The location upon which run commands is queried. @@ -349,13 +354,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.RunCommandListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +372,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -375,9 +385,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -416,7 +428,7 @@ def get( location: str, command_id: str, **kwargs: Any - ) -> "_models.RunCommandDocument": + ) -> _models.RunCommandDocument: """Gets specific run command for a subscription in a location. :param location: The location upon which run commands is queried. @@ -428,13 +440,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RunCommandDocument :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandDocument"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandDocument] request = build_get_request( @@ -443,11 +458,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -473,18 +490,21 @@ def _create_or_update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -497,11 +517,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,11 +554,11 @@ def begin_create_or_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the run command. :param resource_group_name: The name of the resource group. @@ -548,7 +570,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -565,16 +587,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -582,20 +607,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -613,18 +645,21 @@ def _update_initial( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -637,11 +672,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -668,11 +705,11 @@ def begin_update( resource_group_name: str, vm_name: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the run command. :param resource_group_name: The name of the resource group. @@ -683,7 +720,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -700,16 +737,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, @@ -717,20 +757,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -750,13 +797,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -766,11 +816,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,21 +867,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -839,8 +896,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -861,7 +924,7 @@ def get_by_virtual_machine( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the run command. :param resource_group_name: The name of the resource group. @@ -877,13 +940,16 @@ def get_by_virtual_machine( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_by_virtual_machine_request( @@ -894,11 +960,13 @@ def get_by_virtual_machine( api_version=api_version, expand=expand, template_url=self.get_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -926,7 +994,7 @@ def list_by_virtual_machine( vm_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of a Virtual Machine. :param resource_group_name: The name of the resource group. @@ -942,13 +1010,16 @@ def list_by_virtual_machine( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -959,9 +1030,11 @@ def prepare_request(next_link=None): api_version=api_version, expand=expand, template_url=self.list_by_virtual_machine.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -972,9 +1045,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_extensions_operations.py index acc54ee15a40..e09908ead4ec 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -81,14 +82,17 @@ def build_update_request_initial( vmss_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -101,20 +105,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -128,9 +130,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -143,18 +148,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -168,9 +171,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -183,20 +189,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -207,9 +211,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -221,59 +228,58 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetExtensionsOperations(object): - """VirtualMachineScaleSetExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtension') @@ -286,11 +292,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -321,9 +329,9 @@ def begin_create_or_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtension", + extension_parameters: _models.VirtualMachineScaleSetExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to create or update an extension. :param resource_group_name: The name of the resource group. @@ -351,17 +359,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -369,20 +380,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetExtension', 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( @@ -400,17 +418,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] + ) -> _models.VirtualMachineScaleSetExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetExtensionUpdate') @@ -423,11 +444,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -458,9 +481,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, vmss_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetExtension]: """The operation to update an extension. :param resource_group_name: The name of the resource group. @@ -487,17 +510,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, @@ -505,20 +531,27 @@ def begin_update( 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('VirtualMachineScaleSetExtension', 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( @@ -538,13 +571,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vmss_extension_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -554,11 +590,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -603,21 +641,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vmss_extension_name=vmss_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -627,8 +670,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -649,7 +698,7 @@ def get( vmss_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetExtension": + ) -> _models.VirtualMachineScaleSetExtension: """The operation to get the extension. :param resource_group_name: The name of the resource group. @@ -665,13 +714,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtension] request = build_get_request( @@ -682,11 +734,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -713,7 +767,7 @@ def list( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetExtensionListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetExtensionListResult]: """Gets a list of all extensions in a VM scale set. :param resource_group_name: The name of the resource group. @@ -727,13 +781,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetExtensionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetExtensionListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetExtensionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -743,9 +800,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -755,9 +814,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py index d14917c7c290..ab2fbe05db21 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_rolling_upgrades_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,6 +16,7 @@ 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 @@ -33,9 +34,12 @@ def build_cancel_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +51,16 @@ def build_cancel_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -69,9 +71,12 @@ def build_start_os_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -83,18 +88,16 @@ def build_start_os_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -105,9 +108,12 @@ def build_start_extension_upgrade_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -119,18 +125,16 @@ def build_start_extension_upgrade_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -141,9 +145,12 @@ def build_get_latest_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest") # pylint: disable=line-too-long path_format_arguments = { @@ -155,42 +162,38 @@ def build_get_latest_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetRollingUpgradesOperations(object): - """VirtualMachineScaleSetRollingUpgradesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetRollingUpgradesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_rolling_upgrades` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _cancel_initial( # pylint: disable=inconsistent-return-statements self, @@ -198,13 +201,16 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_cancel_request_initial( @@ -213,11 +219,13 @@ def _cancel_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._cancel_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -259,20 +267,25 @@ def begin_cancel( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._cancel_initial( + raw_result = self._cancel_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -282,8 +295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -302,13 +321,16 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_os_upgrade_request_initial( @@ -317,11 +339,13 @@ def _start_os_upgrade_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_os_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -365,20 +389,25 @@ def begin_start_os_upgrade( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._start_os_upgrade_initial( + raw_result = self._start_os_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -388,8 +417,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -408,13 +443,16 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta vm_scale_set_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_extension_upgrade_request_initial( @@ -423,11 +461,13 @@ def _start_extension_upgrade_initial( # pylint: disable=inconsistent-return-sta subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_extension_upgrade_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -471,20 +511,25 @@ def begin_start_extension_upgrade( # pylint: disable=inconsistent-return-statem :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._start_extension_upgrade_initial( + raw_result = self._start_extension_upgrade_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -494,8 +539,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -514,7 +565,7 @@ def get_latest( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.RollingUpgradeStatusInfo": + ) -> _models.RollingUpgradeStatusInfo: """Gets the status of the latest virtual machine scale set rolling upgrade. :param resource_group_name: The name of the resource group. @@ -526,13 +577,16 @@ def get_latest( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RollingUpgradeStatusInfo :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RollingUpgradeStatusInfo"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RollingUpgradeStatusInfo] request = build_get_latest_request( @@ -541,11 +595,13 @@ def get_latest( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_latest.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py index 2bd282cc8824..fa327bdcf4e5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_vm_extensions_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,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 .. 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() @@ -35,14 +35,17 @@ def build_create_or_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtension] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -56,20 +59,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -83,14 +84,17 @@ def build_update_request_initial( vm_extension_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMExtensionUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -104,20 +108,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -132,9 +134,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -148,18 +153,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -174,9 +177,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions/{vmExtensionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -190,20 +196,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -217,9 +221,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/extensions") # pylint: disable=line-too-long path_format_arguments = { @@ -232,44 +239,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMExtensionsOperations(object): - """VirtualMachineScaleSetVMExtensionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -277,17 +280,20 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtension') @@ -301,11 +307,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -337,9 +345,9 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtension", + extension_parameters: _models.VirtualMachineScaleSetVMExtension, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to create or update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -368,17 +376,20 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -387,20 +398,27 @@ def begin_create_or_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -419,17 +437,20 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] + ) -> _models.VirtualMachineScaleSetVMExtension: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] _json = self._serialize.body(extension_parameters, 'VirtualMachineScaleSetVMExtensionUpdate') @@ -443,11 +464,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -475,9 +498,9 @@ def begin_update( vm_scale_set_name: str, instance_id: str, vm_extension_name: str, - extension_parameters: "_models.VirtualMachineScaleSetVMExtensionUpdate", + extension_parameters: _models.VirtualMachineScaleSetVMExtensionUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVMExtension"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVMExtension]: """The operation to update the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -506,17 +529,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVMExtension] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -525,20 +551,27 @@ def begin_update( 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('VirtualMachineScaleSetVMExtension', 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( @@ -559,13 +592,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements vm_extension_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -576,11 +612,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -628,22 +666,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, vm_extension_name=vm_extension_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -653,8 +696,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -676,7 +725,7 @@ def get( vm_extension_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtension": + ) -> _models.VirtualMachineScaleSetVMExtension: """The operation to get the VMSS VM extension. :param resource_group_name: The name of the resource group. @@ -694,13 +743,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVMExtension :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtension] request = build_get_request( @@ -712,11 +764,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -745,7 +799,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMExtensionsListResult": + ) -> _models.VirtualMachineScaleSetVMExtensionsListResult: """The operation to get all extensions of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -761,13 +815,16 @@ def list( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVMExtensionsListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMExtensionsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMExtensionsListResult] request = build_list_request( @@ -778,11 +835,13 @@ def list( api_version=api_version, 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 - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py index 304f125556eb..f898ee907c78 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_vm_run_commands_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -36,14 +36,17 @@ def build_create_or_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommand] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -57,20 +60,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -84,14 +85,17 @@ def build_update_request_initial( run_command_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineRunCommandUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -105,20 +109,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -133,9 +135,12 @@ def build_delete_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -149,18 +154,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -175,9 +178,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}") # pylint: disable=line-too-long path_format_arguments = { @@ -191,20 +197,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -218,9 +222,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands") # pylint: disable=line-too-long path_format_arguments = { @@ -233,44 +240,40 @@ def build_list_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineScaleSetVMRunCommandsOperations(object): - """VirtualMachineScaleSetVMRunCommandsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMRunCommandsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vm_run_commands` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, @@ -278,18 +281,21 @@ def _create_or_update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommand') @@ -303,11 +309,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -339,11 +347,11 @@ def begin_create_or_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommand", + run_command: _models.VirtualMachineRunCommand, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to create or update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -356,7 +364,7 @@ def begin_create_or_update( :type run_command_name: str :param run_command: Parameters supplied to the Create Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -373,16 +381,19 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -391,20 +402,27 @@ def begin_create_or_update( 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('VirtualMachineRunCommand', 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( @@ -423,18 +441,21 @@ def _update_initial( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] + ) -> _models.VirtualMachineRunCommand: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] _json = self._serialize.body(run_command, 'VirtualMachineRunCommandUpdate') @@ -448,11 +469,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -480,11 +503,11 @@ def begin_update( vm_scale_set_name: str, instance_id: str, run_command_name: str, - run_command: "_models.VirtualMachineRunCommandUpdate", + run_command: _models.VirtualMachineRunCommandUpdate, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.VirtualMachineRunCommand"]: + ) -> LROPoller[_models.VirtualMachineRunCommand]: """The operation to update the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -497,7 +520,7 @@ def begin_update( :type run_command_name: str :param run_command: Parameters supplied to the Update Virtual Machine RunCommand operation. :type run_command: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommandUpdate - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -514,16 +537,19 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -532,20 +558,27 @@ def begin_update( 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('VirtualMachineRunCommand', 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( @@ -566,13 +599,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements run_command_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -583,11 +619,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -635,22 +673,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, run_command_name=run_command_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -660,8 +703,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -683,7 +732,7 @@ def get( run_command_name: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.VirtualMachineRunCommand": + ) -> _models.VirtualMachineRunCommand: """The operation to get the VMSS VM run command. :param resource_group_name: The name of the resource group. @@ -701,13 +750,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommand :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommand"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommand] request = build_get_request( @@ -719,11 +771,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -752,7 +806,7 @@ def list( instance_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineRunCommandsListResult"]: + ) -> Iterable[_models.VirtualMachineRunCommandsListResult]: """The operation to get all run commands of an instance in Virtual Machine Scaleset. :param resource_group_name: The name of the resource group. @@ -770,13 +824,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineRunCommandsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineRunCommandsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineRunCommandsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -788,9 +845,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -802,9 +861,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_vms_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_vms_operations.py index b49e43678e34..d13ac9cef6bb 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_vms_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_set_vms_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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() @@ -35,14 +35,17 @@ def build_reimage_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -55,20 +58,18 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -82,9 +83,12 @@ def build_reimage_all_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -97,18 +101,16 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -120,9 +122,12 @@ def build_deallocate_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -135,18 +140,16 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -157,14 +160,17 @@ def build_update_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVM] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -177,20 +183,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -206,9 +210,12 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -221,20 +228,18 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -248,9 +253,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}") # pylint: disable=line-too-long path_format_arguments = { @@ -263,20 +271,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -288,9 +294,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -303,18 +312,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -329,9 +336,12 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -343,24 +353,22 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if select is not None: - _query_parameters['$select'] = _SERIALIZER.query("select", select, 'str') + _params['$select'] = _SERIALIZER.query("select", select, 'str') 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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -374,9 +382,12 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -389,20 +400,18 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -414,9 +423,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -429,18 +441,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -452,9 +462,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -467,18 +480,16 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -490,9 +501,12 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -505,18 +519,16 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -530,9 +542,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -545,20 +560,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -570,9 +583,12 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -585,18 +601,16 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -608,9 +622,12 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -623,18 +640,16 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -645,14 +660,17 @@ def build_run_command_request_initial( instance_id: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -665,63 +683,62 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetVMsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetVMsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetVMsOperations: # 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_set_vms` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_vm_reimage_input is not None: _json = self._serialize.body(vm_scale_set_vm_reimage_input, 'VirtualMachineScaleSetVMReimageParameters') @@ -737,11 +754,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -764,7 +783,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, instance_id: str, - vm_scale_set_vm_reimage_input: Optional["_models.VirtualMachineScaleSetVMReimageParameters"] = None, + vm_scale_set_vm_reimage_input: Optional[_models.VirtualMachineScaleSetVMReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) a specific virtual machine in a VM scale set. @@ -791,17 +810,20 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -809,6 +831,8 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -818,8 +842,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -839,13 +869,16 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reimage_all_request_initial( @@ -855,11 +888,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -905,21 +940,26 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -929,8 +969,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -950,13 +996,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -966,11 +1015,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1017,21 +1068,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1041,8 +1097,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1060,17 +1122,20 @@ def _update_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] + ) -> _models.VirtualMachineScaleSetVM: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetVM') @@ -1083,11 +1148,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1118,9 +1185,9 @@ def begin_update( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.VirtualMachineScaleSetVM", + parameters: _models.VirtualMachineScaleSetVM, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSetVM"]: + ) -> LROPoller[_models.VirtualMachineScaleSetVM]: """Updates a virtual machine of a VM scale set. :param resource_group_name: The name of the resource group. @@ -1146,17 +1213,20 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVM] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -1164,20 +1234,27 @@ def begin_update( 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('VirtualMachineScaleSetVM', 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( @@ -1198,13 +1275,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1215,11 +1295,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1268,22 +1350,27 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1293,8 +1380,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1315,7 +1408,7 @@ def get( instance_id: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVM": + ) -> _models.VirtualMachineScaleSetVM: """Gets a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1333,13 +1426,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVM :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVM"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVM] request = build_get_request( @@ -1350,11 +1446,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1382,7 +1480,7 @@ def get_instance_view( vm_scale_set_name: str, instance_id: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetVMInstanceView": + ) -> _models.VirtualMachineScaleSetVMInstanceView: """Gets the status of a virtual machine from a VM scale set. :param resource_group_name: The name of the resource group. @@ -1396,13 +1494,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVMInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMInstanceView] request = build_get_instance_view_request( @@ -1412,11 +1513,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1446,7 +1549,7 @@ def list( select: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetVMListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetVMListResult]: """Gets a list of all virtual machines in a VM scale sets. :param resource_group_name: The name of the resource group. @@ -1470,13 +1573,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetVMListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetVMListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetVMListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1489,9 +1595,11 @@ def prepare_request(next_link=None): select=select, 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: @@ -1504,9 +1612,11 @@ def prepare_request(next_link=None): select=select, 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 @@ -1547,13 +1657,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -1564,11 +1677,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1620,22 +1735,27 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1645,8 +1765,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1666,13 +1792,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements instance_id: 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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -1682,11 +1811,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1731,21 +1862,26 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1755,8 +1891,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1776,13 +1918,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -1792,11 +1937,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1841,21 +1988,26 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1865,8 +2017,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1886,13 +2044,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements instance_id: 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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -1902,11 +2063,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1952,21 +2115,26 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1976,8 +2144,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1998,7 +2172,7 @@ def retrieve_boot_diagnostics_data( instance_id: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs of boot diagnostic logs for a virtual machine in a VM scale set. @@ -2017,13 +2191,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -2034,11 +2211,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2066,13 +2245,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme instance_id: 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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2082,11 +2264,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2131,21 +2315,26 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2155,8 +2344,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2190,13 +2385,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -2206,11 +2404,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2232,18 +2432,21 @@ def _run_command_initial( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -2256,11 +2459,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2289,11 +2494,11 @@ def begin_run_command( resource_group_name: str, vm_scale_set_name: str, instance_id: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on a virtual machine in a VM scale set. :param resource_group_name: The name of the resource group. @@ -2304,7 +2509,7 @@ def begin_run_command( :type instance_id: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2022_03_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -2320,16 +2525,19 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, instance_id=instance_id, @@ -2337,20 +2545,27 @@ def begin_run_command( 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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_sets_operations.py index 4aa717b2dced..947da4cf274e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_scale_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_create_or_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_update_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -159,9 +162,12 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,20 +179,18 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -199,9 +203,12 @@ def build_get_request( expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -213,20 +220,18 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, + headers=_headers, **kwargs ) @@ -236,14 +241,17 @@ def build_deallocate_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -255,20 +263,18 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -280,15 +286,18 @@ def build_delete_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/delete") # pylint: disable=line-too-long path_format_arguments = { @@ -300,22 +309,20 @@ def build_delete_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -328,9 +335,12 @@ def build_get_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -342,18 +352,16 @@ def build_get_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -363,9 +371,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets") # pylint: disable=line-too-long path_format_arguments = { @@ -376,18 +387,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -396,9 +405,12 @@ def build_list_all_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachineScaleSets") path_format_arguments = { @@ -408,18 +420,16 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -430,9 +440,12 @@ def build_list_skus_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/skus") # pylint: disable=line-too-long path_format_arguments = { @@ -444,18 +457,16 @@ def build_list_skus_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -466,9 +477,12 @@ def build_get_os_upgrade_history_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osUpgradeHistory") # pylint: disable=line-too-long path_format_arguments = { @@ -480,18 +494,16 @@ def build_get_os_upgrade_history_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -501,15 +513,18 @@ def build_power_off_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/poweroff") # pylint: disable=line-too-long path_format_arguments = { @@ -521,22 +536,20 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -548,14 +561,17 @@ def build_restart_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -567,20 +583,18 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -592,14 +606,17 @@ def build_start_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -611,20 +628,18 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -636,14 +651,17 @@ def build_redeploy_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -655,20 +673,18 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -680,14 +696,17 @@ def build_perform_maintenance_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -699,20 +718,18 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -724,14 +741,17 @@ def build_update_instances_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceRequiredIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/manualupgrade") # pylint: disable=line-too-long path_format_arguments = { @@ -743,20 +763,18 @@ def build_update_instances_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -768,14 +786,17 @@ def build_reimage_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -787,20 +808,18 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -812,14 +831,17 @@ def build_reimage_all_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/reimageall") # pylint: disable=line-too-long path_format_arguments = { @@ -831,20 +853,18 @@ def build_reimage_all_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -861,9 +881,12 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( placement_group_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/forceRecoveryServiceFabricPlatformUpdateDomainWalk") # pylint: disable=line-too-long path_format_arguments = { @@ -875,23 +898,21 @@ def build_force_recovery_service_fabric_platform_update_domain_walk_request( _url = _format_url_section(_url, **path_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['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['platformUpdateDomain'] = _SERIALIZER.query("platform_update_domain", platform_update_domain, 'int') if zone is not None: - _query_parameters['zone'] = _SERIALIZER.query("zone", zone, 'str') + _params['zone'] = _SERIALIZER.query("zone", zone, 'str') if placement_group_id is not None: - _query_parameters['placementGroupId'] = _SERIALIZER.query("placement_group_id", placement_group_id, 'str') + _params['placementGroupId'] = _SERIALIZER.query("placement_group_id", placement_group_id, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -901,14 +922,17 @@ def build_convert_to_single_placement_group_request( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VMScaleSetConvertToSinglePlacementGroupInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/convertToSinglePlacementGroup") # pylint: disable=line-too-long path_format_arguments = { @@ -920,20 +944,18 @@ def build_convert_to_single_placement_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -945,14 +967,17 @@ def build_set_orchestration_service_state_request_initial( vm_scale_set_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.OrchestrationServiceStateInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/setOrchestrationServiceState") # pylint: disable=line-too-long path_format_arguments = { @@ -964,53 +989,49 @@ def build_set_orchestration_service_state_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachineScaleSetsOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachineScaleSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineScaleSetsOperations: # 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_scale_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets all the VM scale sets under the specified subscription for the specified location. :param location: The location for which VM scale sets under the subscription are queried. @@ -1022,13 +1043,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1037,9 +1061,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -1048,9 +1074,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1087,17 +1115,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSet') @@ -1109,11 +1140,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1143,9 +1176,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSet", + parameters: _models.VirtualMachineScaleSet, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Create or update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1168,37 +1201,47 @@ def begin_create_or_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1215,17 +1258,20 @@ def _update_initial( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] + ) -> _models.VirtualMachineScaleSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] _json = self._serialize.body(parameters, 'VirtualMachineScaleSetUpdate') @@ -1237,11 +1283,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1267,9 +1315,9 @@ def begin_update( self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VirtualMachineScaleSetUpdate", + parameters: _models.VirtualMachineScaleSetUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineScaleSet"]: + ) -> LROPoller[_models.VirtualMachineScaleSet]: """Update a VM scale set. :param resource_group_name: The name of the resource group. @@ -1292,37 +1340,47 @@ def begin_update( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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('VirtualMachineScaleSet', 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( @@ -1342,13 +1400,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1358,11 +1419,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1408,21 +1471,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1432,8 +1500,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1453,7 +1527,7 @@ def get( vm_scale_set_name: str, expand: Optional[Union[str, "_models.ExpandTypesForGetVMScaleSets"]] = None, **kwargs: Any - ) -> "_models.VirtualMachineScaleSet": + ) -> _models.VirtualMachineScaleSet: """Display information about a virtual machine scale set. :param resource_group_name: The name of the resource group. @@ -1469,13 +1543,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSet] request = build_get_request( @@ -1485,11 +1562,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1514,17 +1593,20 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -1539,11 +1621,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1565,7 +1649,7 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and @@ -1592,23 +1676,28 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1618,8 +1707,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1636,18 +1731,21 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -1660,11 +1758,13 @@ def _delete_instances_initial( # pylint: disable=inconsistent-return-statements json=_json, force_deletion=force_deletion, template_url=self._delete_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1686,7 +1786,7 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, force_deletion: Optional[bool] = None, **kwargs: Any ) -> LROPoller[None]: @@ -1714,17 +1814,20 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_instances_initial( + raw_result = self._delete_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, @@ -1732,6 +1835,8 @@ def begin_delete_instances( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1741,8 +1846,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1761,7 +1872,7 @@ def get_instance_view( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> "_models.VirtualMachineScaleSetInstanceView": + ) -> _models.VirtualMachineScaleSetInstanceView: """Gets the status of a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -1773,13 +1884,16 @@ def get_instance_view( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetInstanceView] request = build_get_instance_view_request( @@ -1788,11 +1902,13 @@ def get_instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1818,7 +1934,7 @@ def list( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListResult]: """Gets a list of all VM scale sets under a resource group. :param resource_group_name: The name of the resource group. @@ -1830,13 +1946,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1845,9 +1964,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1856,9 +1977,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1895,7 +2018,7 @@ def get_next(next_link=None): def list_all( self, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListWithLinkResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListWithLinkResult]: """Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink is null to fetch all the VM Scale Sets. @@ -1907,13 +2030,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetListWithLinkResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListWithLinkResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListWithLinkResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1921,9 +2047,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1931,9 +2059,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1972,7 +2102,7 @@ def list_skus( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListSkusResult"]: + ) -> Iterable[_models.VirtualMachineScaleSetListSkusResult]: """Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances allowed for each SKU. @@ -1987,13 +2117,16 @@ def list_skus( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetListSkusResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListSkusResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListSkusResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2003,9 +2136,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_skus.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2015,9 +2150,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2056,7 +2193,7 @@ def get_os_upgrade_history( resource_group_name: str, vm_scale_set_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineScaleSetListOSUpgradeHistory"]: + ) -> Iterable[_models.VirtualMachineScaleSetListOSUpgradeHistory]: """Gets list of OS upgrades on a VM scale set instance. :param resource_group_name: The name of the resource group. @@ -2070,13 +2207,16 @@ def get_os_upgrade_history( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineScaleSetListOSUpgradeHistory] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineScaleSetListOSUpgradeHistory] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineScaleSetListOSUpgradeHistory"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2086,9 +2226,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.get_os_upgrade_history.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2098,9 +2240,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2138,17 +2282,20 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2164,11 +2311,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements json=_json, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2191,7 +2340,7 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements resource_group_name: str, vm_scale_set_name: str, skip_shutdown: Optional[bool] = False, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still @@ -2222,17 +2371,20 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, skip_shutdown=skip_shutdown, @@ -2240,6 +2392,8 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2249,8 +2403,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2267,17 +2427,20 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2292,11 +2455,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2318,7 +2483,7 @@ def begin_restart( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts one or more virtual machines in a VM scale set. @@ -2343,23 +2508,28 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2369,8 +2539,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2387,17 +2563,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2412,11 +2591,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2438,7 +2619,7 @@ def begin_start( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Starts one or more virtual machines in a VM scale set. @@ -2463,23 +2644,28 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2489,8 +2675,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2507,17 +2699,20 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2532,11 +2727,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2558,7 +2755,7 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, @@ -2584,23 +2781,28 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2610,8 +2812,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2628,17 +2836,20 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -2653,11 +2864,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2679,7 +2892,7 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances @@ -2707,23 +2920,28 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2733,8 +2951,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2751,17 +2975,20 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceRequiredIDs') @@ -2773,11 +3000,13 @@ def _update_instances_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._update_instances_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2799,7 +3028,7 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: "_models.VirtualMachineScaleSetVMInstanceRequiredIDs", + vm_instance_i_ds: _models.VirtualMachineScaleSetVMInstanceRequiredIDs, **kwargs: Any ) -> LROPoller[None]: """Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. @@ -2823,23 +3052,28 @@ def begin_update_instances( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_instances_initial( + raw_result = self._update_instances_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2849,8 +3083,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2867,17 +3107,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_scale_set_reimage_input is not None: _json = self._serialize.body(vm_scale_set_reimage_input, 'VirtualMachineScaleSetReimageParameters') @@ -2892,11 +3135,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2918,7 +3163,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_scale_set_reimage_input: Optional["_models.VirtualMachineScaleSetReimageParameters"] = None, + vm_scale_set_reimage_input: Optional[_models.VirtualMachineScaleSetReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which @@ -2944,23 +3189,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_scale_set_reimage_input=vm_scale_set_reimage_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2970,8 +3220,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2988,17 +3244,20 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if vm_instance_i_ds is not None: _json = self._serialize.body(vm_instance_i_ds, 'VirtualMachineScaleSetVMInstanceIDs') @@ -3013,11 +3272,13 @@ def _reimage_all_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_all_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3039,7 +3300,7 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_scale_set_name: str, - vm_instance_i_ds: Optional["_models.VirtualMachineScaleSetVMInstanceIDs"] = None, + vm_instance_i_ds: Optional[_models.VirtualMachineScaleSetVMInstanceIDs] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This @@ -3065,23 +3326,28 @@ def begin_reimage_all( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._reimage_all_initial( + raw_result = self._reimage_all_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_name, vm_instance_i_ds=vm_instance_i_ds, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -3091,8 +3357,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -3114,7 +3386,7 @@ def force_recovery_service_fabric_platform_update_domain_walk( zone: Optional[str] = None, placement_group_id: Optional[str] = None, **kwargs: Any - ) -> "_models.RecoveryWalkResponse": + ) -> _models.RecoveryWalkResponse: """Manual platform update domain walk to update virtual machines in a service fabric virtual machine scale set. @@ -3136,13 +3408,16 @@ def force_recovery_service_fabric_platform_update_domain_walk( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RecoveryWalkResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RecoveryWalkResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RecoveryWalkResponse] request = build_force_recovery_service_fabric_platform_update_domain_walk_request( @@ -3154,11 +3429,13 @@ def force_recovery_service_fabric_platform_update_domain_walk( zone=zone, placement_group_id=placement_group_id, template_url=self.force_recovery_service_fabric_platform_update_domain_walk.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3184,7 +3461,7 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.VMScaleSetConvertToSinglePlacementGroupInput", + parameters: _models.VMScaleSetConvertToSinglePlacementGroupInput, **kwargs: Any ) -> None: """Converts SinglePlacementGroup property to false for a existing virtual machine scale set. @@ -3201,14 +3478,17 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st :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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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(parameters, 'VMScaleSetConvertToSinglePlacementGroupInput') @@ -3220,11 +3500,13 @@ def convert_to_single_placement_group( # pylint: disable=inconsistent-return-st content_type=content_type, json=_json, template_url=self.convert_to_single_placement_group.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3245,17 +3527,20 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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(parameters, 'OrchestrationServiceStateInput') @@ -3267,11 +3552,13 @@ def _set_orchestration_service_state_initial( # pylint: disable=inconsistent-re content_type=content_type, json=_json, template_url=self._set_orchestration_service_state_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3293,7 +3580,7 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur self, resource_group_name: str, vm_scale_set_name: str, - parameters: "_models.OrchestrationServiceStateInput", + parameters: _models.OrchestrationServiceStateInput, **kwargs: Any ) -> LROPoller[None]: """Changes ServiceState property for a given service. @@ -3316,23 +3603,28 @@ def begin_set_orchestration_service_state( # pylint: disable=inconsistent-retur :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._set_orchestration_service_state_initial( + raw_result = self._set_orchestration_service_state_initial( # type: ignore resource_group_name=resource_group_name, vm_scale_set_name=vm_scale_set_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) @@ -3342,8 +3634,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_sizes_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_sizes_operations.py index 063267e92dba..c01d6307b1f1 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_sizes_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machine_sizes_operations.py @@ -16,6 +16,7 @@ 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 @@ -31,9 +32,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -44,49 +48,45 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class VirtualMachineSizesOperations(object): - """VirtualMachineSizesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineSizesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machine_sizes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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, location: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """This API is deprecated. Use `Resources Skus `_. @@ -99,13 +99,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -114,9 +117,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -125,9 +130,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machines_operations.py index 581010528233..d5b832917bd2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_01/operations/_virtual_machines_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +34,12 @@ def build_list_by_location_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -47,18 +50,16 @@ def build_list_by_location_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -68,14 +69,17 @@ def build_capture_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineCaptureParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/capture") # pylint: disable=line-too-long path_format_arguments = { @@ -87,20 +91,18 @@ def build_capture_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -112,14 +114,17 @@ def build_create_or_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachine] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -131,20 +136,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -156,14 +159,17 @@ def build_update_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -175,20 +181,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -203,9 +207,12 @@ def build_delete_request_initial( force_deletion: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -217,20 +224,18 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if force_deletion is not None: - _query_parameters['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['forceDeletion'] = _SERIALIZER.query("force_deletion", force_deletion, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -243,9 +248,12 @@ def build_get_request( expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}") # pylint: disable=line-too-long path_format_arguments = { @@ -257,20 +265,18 @@ def build_get_request( _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] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -281,9 +287,12 @@ def build_instance_view_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView") # pylint: disable=line-too-long path_format_arguments = { @@ -295,18 +304,16 @@ def build_instance_view_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -317,9 +324,12 @@ def build_convert_to_managed_disks_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/convertToManagedDisks") # pylint: disable=line-too-long path_format_arguments = { @@ -331,18 +341,16 @@ def build_convert_to_managed_disks_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -355,9 +363,12 @@ def build_deallocate_request_initial( hibernate: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate") # pylint: disable=line-too-long path_format_arguments = { @@ -369,20 +380,18 @@ def build_deallocate_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if hibernate is not None: - _query_parameters['hibernate'] = _SERIALIZER.query("hibernate", hibernate, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['hibernate'] = _SERIALIZER.query("hibernate", hibernate, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -393,9 +402,12 @@ def build_generalize_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/generalize") # pylint: disable=line-too-long path_format_arguments = { @@ -407,18 +419,16 @@ def build_generalize_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -430,9 +440,12 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines") # pylint: disable=line-too-long path_format_arguments = { @@ -443,20 +456,18 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -468,9 +479,12 @@ def build_list_all_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines") path_format_arguments = { @@ -480,22 +494,20 @@ def build_list_all_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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 status_only is not None: - _query_parameters['statusOnly'] = _SERIALIZER.query("status_only", status_only, 'str') + _params['statusOnly'] = _SERIALIZER.query("status_only", status_only, '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, + params=_params, + headers=_headers, **kwargs ) @@ -506,9 +518,12 @@ def build_list_available_sizes_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/vmSizes") # pylint: disable=line-too-long path_format_arguments = { @@ -520,18 +535,16 @@ def build_list_available_sizes_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -544,9 +557,12 @@ def build_power_off_request_initial( skip_shutdown: Optional[bool] = False, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/powerOff") # pylint: disable=line-too-long path_format_arguments = { @@ -558,20 +574,18 @@ def build_power_off_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if skip_shutdown is not None: - _query_parameters['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['skipShutdown'] = _SERIALIZER.query("skip_shutdown", skip_shutdown, 'bool') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -582,9 +596,12 @@ def build_reapply_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reapply") # pylint: disable=line-too-long path_format_arguments = { @@ -596,18 +613,16 @@ def build_reapply_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -618,9 +633,12 @@ def build_restart_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/restart") # pylint: disable=line-too-long path_format_arguments = { @@ -632,18 +650,16 @@ def build_restart_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -654,9 +670,12 @@ def build_start_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start") # pylint: disable=line-too-long path_format_arguments = { @@ -668,18 +687,16 @@ def build_start_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -690,9 +707,12 @@ def build_redeploy_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/redeploy") # pylint: disable=line-too-long path_format_arguments = { @@ -704,18 +724,16 @@ def build_redeploy_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -725,14 +743,17 @@ def build_reimage_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineReimageParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/reimage") # pylint: disable=line-too-long path_format_arguments = { @@ -744,20 +765,18 @@ def build_reimage_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -772,9 +791,12 @@ def build_retrieve_boot_diagnostics_data_request( sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/retrieveBootDiagnosticsData") # pylint: disable=line-too-long path_format_arguments = { @@ -786,20 +808,18 @@ def build_retrieve_boot_diagnostics_data_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if sas_uri_expiration_time_in_minutes is not None: - _query_parameters['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['sasUriExpirationTimeInMinutes'] = _SERIALIZER.query("sas_uri_expiration_time_in_minutes", sas_uri_expiration_time_in_minutes, 'int') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -810,9 +830,12 @@ def build_perform_maintenance_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/performMaintenance") # pylint: disable=line-too-long path_format_arguments = { @@ -824,18 +847,16 @@ def build_perform_maintenance_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -846,9 +867,12 @@ def build_simulate_eviction_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction") # pylint: disable=line-too-long path_format_arguments = { @@ -860,18 +884,16 @@ def build_simulate_eviction_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -882,9 +904,12 @@ def build_assess_patches_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/assessPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -896,18 +921,16 @@ def build_assess_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -917,14 +940,17 @@ def build_install_patches_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.VirtualMachineInstallPatchesParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/installPatches") # pylint: disable=line-too-long path_format_arguments = { @@ -936,20 +962,18 @@ def build_install_patches_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -961,14 +985,17 @@ def build_run_command_request_initial( vm_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.RunCommandInput] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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") - accept = "application/json, text/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/runCommand") # pylint: disable=line-too-long path_format_arguments = { @@ -980,53 +1007,49 @@ def build_run_command_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class VirtualMachinesOperations(object): # pylint: disable=too-many-public-methods - """VirtualMachinesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: # 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.compute.v2022_03_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_01.ComputeManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) 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.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Gets all the virtual machines under the specified subscription for the specified location. :param location: The location for which virtual machines under the subscription are queried. @@ -1038,13 +1061,16 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1053,9 +1079,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, 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: @@ -1064,9 +1092,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1103,17 +1133,20 @@ def _capture_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineCaptureResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineCaptureResult"]] + ) -> Optional[_models.VirtualMachineCaptureResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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.VirtualMachineCaptureResult]] _json = self._serialize.body(parameters, 'VirtualMachineCaptureParameters') @@ -1125,11 +1158,13 @@ def _capture_initial( content_type=content_type, json=_json, template_url=self._capture_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1157,9 +1192,9 @@ def begin_capture( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineCaptureParameters", + parameters: _models.VirtualMachineCaptureParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineCaptureResult"]: + ) -> LROPoller[_models.VirtualMachineCaptureResult]: """Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to create similar VMs. @@ -1183,37 +1218,47 @@ def begin_capture( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineCaptureResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineCaptureResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineCaptureResult"] 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._capture_initial( + raw_result = self._capture_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachineCaptureResult', 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( @@ -1230,17 +1275,20 @@ def _create_or_update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachine') @@ -1252,11 +1300,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1286,9 +1336,9 @@ def begin_create_or_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachine", + parameters: _models.VirtualMachine, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to create or update a virtual machine. Please note some properties can be set only during virtual machine creation. @@ -1311,37 +1361,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1358,17 +1418,20 @@ def _update_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> _models.VirtualMachine: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] _json = self._serialize.body(parameters, 'VirtualMachineUpdate') @@ -1380,11 +1443,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1410,9 +1475,9 @@ def begin_update( self, resource_group_name: str, vm_name: str, - parameters: "_models.VirtualMachineUpdate", + parameters: _models.VirtualMachineUpdate, **kwargs: Any - ) -> LROPoller["_models.VirtualMachine"]: + ) -> LROPoller[_models.VirtualMachine]: """The operation to update a virtual machine. :param resource_group_name: The name of the resource group. @@ -1434,37 +1499,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachine] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('VirtualMachine', 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( @@ -1484,13 +1559,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements force_deletion: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -1500,11 +1578,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, force_deletion=force_deletion, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1550,21 +1630,26 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, force_deletion=force_deletion, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1574,8 +1659,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1595,7 +1686,7 @@ def get( vm_name: str, expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Retrieves information about the model view or the instance view of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1613,13 +1704,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachine :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] request = build_get_request( @@ -1629,11 +1723,13 @@ def get( 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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1660,7 +1756,7 @@ def instance_view( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> "_models.VirtualMachineInstanceView": + ) -> _models.VirtualMachineInstanceView: """Retrieves information about the run-time state of a virtual machine. :param resource_group_name: The name of the resource group. @@ -1672,13 +1768,16 @@ def instance_view( :rtype: ~azure.mgmt.compute.v2022_03_01.models.VirtualMachineInstanceView :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstanceView"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstanceView] request = build_instance_view_request( @@ -1687,11 +1786,13 @@ def instance_view( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.instance_view.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1718,13 +1819,16 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st vm_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_convert_to_managed_disks_request_initial( @@ -1733,11 +1837,13 @@ def _convert_to_managed_disks_initial( # pylint: disable=inconsistent-return-st subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._convert_to_managed_disks_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1780,20 +1886,25 @@ def begin_convert_to_managed_disks( # pylint: disable=inconsistent-return-state :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._convert_to_managed_disks_initial( + raw_result = self._convert_to_managed_disks_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1803,8 +1914,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1824,13 +1941,16 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements hibernate: Optional[bool] = None, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_deallocate_request_initial( @@ -1840,11 +1960,13 @@ def _deallocate_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, hibernate=hibernate, template_url=self._deallocate_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1891,21 +2013,26 @@ def begin_deallocate( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._deallocate_initial( + raw_result = self._deallocate_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, hibernate=hibernate, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1915,8 +2042,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1952,13 +2085,16 @@ def generalize( # pylint: disable=inconsistent-return-statements :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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_generalize_request( @@ -1967,11 +2103,13 @@ def generalize( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.generalize.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1994,7 +2132,7 @@ def list( resource_group_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines. @@ -2012,13 +2150,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2028,9 +2169,11 @@ def prepare_request(next_link=None): api_version=api_version, 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: @@ -2040,9 +2183,11 @@ def prepare_request(next_link=None): api_version=api_version, 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 @@ -2081,7 +2226,7 @@ def list_all( status_only: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.VirtualMachineListResult"]: + ) -> Iterable[_models.VirtualMachineListResult]: """Lists all of the virtual machines in the specified subscription. Use the nextLink property in the response to get the next page of virtual machines. @@ -2100,13 +2245,16 @@ def list_all( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2116,9 +2264,11 @@ def prepare_request(next_link=None): status_only=status_only, filter=filter, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2128,9 +2278,11 @@ def prepare_request(next_link=None): status_only=status_only, 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 @@ -2169,7 +2321,7 @@ def list_available_sizes( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Iterable["_models.VirtualMachineSizeListResult"]: + ) -> Iterable[_models.VirtualMachineSizeListResult]: """Lists all available virtual machine sizes to which the specified virtual machine can be resized. @@ -2184,13 +2336,16 @@ def list_available_sizes( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineSizeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineSizeListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineSizeListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -2200,9 +2355,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list_available_sizes.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -2212,9 +2369,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2254,13 +2413,16 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements skip_shutdown: Optional[bool] = False, **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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_power_off_request_initial( @@ -2270,11 +2432,13 @@ def _power_off_initial( # pylint: disable=inconsistent-return-statements api_version=api_version, skip_shutdown=skip_shutdown, template_url=self._power_off_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2322,21 +2486,26 @@ def begin_power_off( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._power_off_initial( + raw_result = self._power_off_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, skip_shutdown=skip_shutdown, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2346,8 +2515,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2366,13 +2541,16 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_reapply_request_initial( @@ -2381,11 +2559,13 @@ def _reapply_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._reapply_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2427,20 +2607,25 @@ def begin_reapply( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._reapply_initial( + raw_result = self._reapply_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2450,8 +2635,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2470,13 +2661,16 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_restart_request_initial( @@ -2485,11 +2679,13 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._restart_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2531,20 +2727,25 @@ def begin_restart( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2554,8 +2755,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2574,13 +2781,16 @@ def _start_initial( # pylint: disable=inconsistent-return-statements vm_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_start_request_initial( @@ -2589,11 +2799,13 @@ def _start_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._start_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2635,20 +2847,25 @@ def begin_start( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2658,8 +2875,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2678,13 +2901,16 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements vm_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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_redeploy_request_initial( @@ -2693,11 +2919,13 @@ def _redeploy_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._redeploy_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2739,20 +2967,25 @@ def begin_redeploy( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._redeploy_initial( + raw_result = self._redeploy_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -2762,8 +2995,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2780,17 +3019,20 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **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 = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] if parameters is not None: _json = self._serialize.body(parameters, 'VirtualMachineReimageParameters') @@ -2805,11 +3047,13 @@ def _reimage_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, template_url=self._reimage_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2831,7 +3075,7 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, vm_name: str, - parameters: Optional["_models.VirtualMachineReimageParameters"] = None, + parameters: Optional[_models.VirtualMachineReimageParameters] = None, **kwargs: Any ) -> LROPoller[None]: """Reimages the virtual machine which has an ephemeral OS disk back to its initial state. @@ -2855,23 +3099,28 @@ def begin_reimage( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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] + 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._reimage_initial( + raw_result = self._reimage_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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) @@ -2881,8 +3130,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -2902,7 +3157,7 @@ def retrieve_boot_diagnostics_data( vm_name: str, sas_uri_expiration_time_in_minutes: Optional[int] = None, **kwargs: Any - ) -> "_models.RetrieveBootDiagnosticsDataResult": + ) -> _models.RetrieveBootDiagnosticsDataResult: """The operation to retrieve SAS URIs for a virtual machine's boot diagnostic logs. :param resource_group_name: The name of the resource group. @@ -2918,13 +3173,16 @@ def retrieve_boot_diagnostics_data( :rtype: ~azure.mgmt.compute.v2022_03_01.models.RetrieveBootDiagnosticsDataResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RetrieveBootDiagnosticsDataResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RetrieveBootDiagnosticsDataResult] request = build_retrieve_boot_diagnostics_data_request( @@ -2934,11 +3192,13 @@ def retrieve_boot_diagnostics_data( api_version=api_version, sas_uri_expiration_time_in_minutes=sas_uri_expiration_time_in_minutes, template_url=self.retrieve_boot_diagnostics_data.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -2965,13 +3225,16 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme vm_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', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_perform_maintenance_request_initial( @@ -2980,11 +3243,13 @@ def _perform_maintenance_initial( # pylint: disable=inconsistent-return-stateme subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._perform_maintenance_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3026,20 +3291,25 @@ def begin_perform_maintenance( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-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._perform_maintenance_initial( + raw_result = self._perform_maintenance_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -3049,8 +3319,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -3081,13 +3357,16 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements :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 {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_simulate_eviction_request( @@ -3096,11 +3375,13 @@ def simulate_eviction( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.simulate_eviction.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3122,14 +3403,17 @@ def _assess_patches_initial( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> Optional["_models.VirtualMachineAssessPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineAssessPatchesResult"]] + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] request = build_assess_patches_request_initial( @@ -3138,11 +3422,13 @@ def _assess_patches_initial( subscription_id=self._config.subscription_id, api_version=api_version, template_url=self._assess_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3171,7 +3457,7 @@ def begin_assess_patches( resource_group_name: str, vm_name: str, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineAssessPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: """Assess patches on the VM. :param resource_group_name: The name of the resource group. @@ -3192,34 +3478,44 @@ def begin_assess_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineAssessPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineAssessPatchesResult"] 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._assess_patches_initial( + raw_result = self._assess_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineAssessPatchesResult', 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( @@ -3236,17 +3532,20 @@ def _install_patches_initial( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> Optional["_models.VirtualMachineInstallPatchesResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachineInstallPatchesResult"]] + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # 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.VirtualMachineInstallPatchesResult]] _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') @@ -3258,11 +3557,13 @@ def _install_patches_initial( content_type=content_type, json=_json, template_url=self._install_patches_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3290,9 +3591,9 @@ def begin_install_patches( self, resource_group_name: str, vm_name: str, - install_patches_input: "_models.VirtualMachineInstallPatchesParameters", + install_patches_input: _models.VirtualMachineInstallPatchesParameters, **kwargs: Any - ) -> LROPoller["_models.VirtualMachineInstallPatchesResult"]: + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: """Installs patches on the VM. :param resource_group_name: The name of the resource group. @@ -3316,37 +3617,47 @@ def begin_install_patches( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.VirtualMachineInstallPatchesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstallPatchesResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineInstallPatchesResult"] 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._install_patches_initial( + raw_result = self._install_patches_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_name, install_patches_input=install_patches_input, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineInstallPatchesResult', 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( @@ -3363,18 +3674,21 @@ def _run_command_initial( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.RunCommandResult"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.RunCommandResult"]] + ) -> Optional[_models.RunCommandResult]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.RunCommandResult]] _json = self._serialize.body(parameters, 'RunCommandInput') @@ -3386,11 +3700,13 @@ def _run_command_initial( content_type=content_type, json=_json, template_url=self._run_command_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -3418,11 +3734,11 @@ def begin_run_command( self, resource_group_name: str, vm_name: str, - parameters: "_models.RunCommandInput", + parameters: _models.RunCommandInput, *, content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.RunCommandResult"]: + ) -> LROPoller[_models.RunCommandResult]: """Run command on the VM. :param resource_group_name: The name of the resource group. @@ -3431,7 +3747,7 @@ def begin_run_command( :type vm_name: str :param parameters: Parameters supplied to the Run command operation. :type parameters: ~azure.mgmt.compute.v2022_03_01.models.RunCommandInput - :keyword content_type: Media type of the body sent to the API. Possible values are: + :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 @@ -3447,36 +3763,46 @@ def begin_run_command( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_01.models.RunCommandResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RunCommandResult] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RunCommandResult"] 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._run_command_initial( + raw_result = self._run_command_initial( # type: ignore resource_group_name=resource_group_name, vm_name=vm_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('RunCommandResult', 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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/__init__.py index fd39b8a6c901..836b75d11272 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/__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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_compute_management_client.py index 44bbb01f0844..68f993315659 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_compute_management_client.py @@ -65,11 +65,21 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_restore_point = DiskRestorePointOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py index ae5e925f0035..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "27.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/__init__.py index 9c044a7dd939..184d455419cc 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/_compute_management_client.py index ad3bbd383217..8ebe7bf47df5 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/_compute_management_client.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/_compute_management_client.py @@ -65,11 +65,21 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.disks = DisksOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_accesses = DiskAccessesOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_encryption_sets = DiskEncryptionSetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.disk_restore_point = DiskRestorePointOperations(self._client, self._config, self._serialize, self._deserialize) - self.snapshots = SnapshotsOperations(self._client, self._config, self._serialize, self._deserialize) + self.disks = DisksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_accesses = DiskAccessesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_encryption_sets = DiskEncryptionSetsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.disk_restore_point = DiskRestorePointOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.snapshots = SnapshotsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/__init__.py index 1c2791c4cde3..82801b1610e8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/__init__.py @@ -12,6 +12,9 @@ from ._disk_restore_point_operations import DiskRestorePointOperations from ._snapshots_operations import SnapshotsOperations +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__ = [ 'DisksOperations', 'DiskAccessesOperations', @@ -19,3 +22,5 @@ 'DiskRestorePointOperations', 'SnapshotsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disk_accesses_operations.py index b7a5ab441f00..458a8277afc3 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskAccessesOperations: - """DiskAccessesOperations async operations. - - You 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.compute.v2022_03_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_02.aio.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskAccess"]: + ) -> AsyncLROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_02.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -340,11 +372,13 @@ async def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskAccessList"]: + ) -> AsyncIterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -626,7 +690,7 @@ async def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -640,13 +704,16 @@ async def get_private_link_resources( :rtype: ~azure.mgmt.compute.v2022_03_02.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', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -655,11 +722,13 @@ async def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -685,17 +754,20 @@ async def _update_a_private_endpoint_connection_initial( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: 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(private_endpoint_connection, 'PrivateEndpointConnection') @@ -708,11 +780,13 @@ async def _update_a_private_endpoint_connection_initial( content_type=content_type, json=_json, template_url=self._update_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -743,9 +817,9 @@ async def begin_update_a_private_endpoint_connection( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection under disk access resource, this can't be used to create a new private endpoint connection. @@ -775,17 +849,20 @@ async def begin_update_a_private_endpoint_connection( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: 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] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_a_private_endpoint_connection_initial( + raw_result = await self._update_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -793,20 +870,27 @@ async def begin_update_a_private_endpoint_connection( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -826,7 +910,7 @@ async def get_a_private_endpoint_connection( disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about a private endpoint connection under a disk access resource. :param resource_group_name: The name of the resource group. @@ -842,13 +926,16 @@ async def get_a_private_endpoint_connection( :rtype: ~azure.mgmt.compute.v2022_03_02.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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_a_private_endpoint_connection_request( @@ -858,11 +945,13 @@ async def get_a_private_endpoint_connection( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get_a_private_endpoint_connection.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -890,13 +979,16 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inco private_endpoint_connection_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', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_a_private_endpoint_connection_request_initial( @@ -906,11 +998,13 @@ async def _delete_a_private_endpoint_connection_initial( # pylint: disable=inco private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -957,21 +1051,26 @@ async def begin_delete_a_private_endpoint_connection( # pylint: disable=inconsi :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_a_private_endpoint_connection_initial( + raw_result = await self._delete_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -981,8 +1080,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1001,7 +1106,7 @@ def list_private_endpoint_connections( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List information about private endpoint connections under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1017,13 +1122,16 @@ def list_private_endpoint_connections( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_02.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - 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: @@ -1033,9 +1141,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=self.list_private_endpoint_connections.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1045,9 +1155,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disk_encryption_sets_operations.py index 5a6aba3b7536..253554ef5573 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskEncryptionSetsOperations: - """DiskEncryptionSetsOperations async operations. - - You 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.compute.v2022_03_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_02.aio.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -135,37 +139,47 @@ async def begin_create_or_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -182,17 +196,20 @@ async def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -204,11 +221,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -238,9 +257,9 @@ async def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.DiskEncryptionSet"]: + ) -> AsyncLROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -266,37 +285,47 @@ async def begin_update( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -315,7 +344,7 @@ async def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -329,13 +358,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -344,11 +376,13 @@ async def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -375,13 +409,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -390,11 +427,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,20 +477,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -461,8 +505,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -480,7 +530,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -492,13 +542,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -507,9 +560,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -518,9 +573,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -557,7 +614,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskEncryptionSetList"]: + ) -> AsyncIterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -567,13 +624,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -581,9 +641,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -591,9 +653,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -632,7 +696,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ResourceUriList"]: + ) -> AsyncIterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -647,13 +711,16 @@ def list_associated_resources( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_02.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -663,9 +730,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_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,9 +744,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disk_restore_point_operations.py index 01425f1e9df0..506398452345 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disk_restore_point_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DiskRestorePointOperations: - """DiskRestorePointOperations async operations. - - You 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.compute.v2022_03_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_02.aio.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.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( @@ -55,7 +54,7 @@ async def get( vm_restore_point_name: str, disk_restore_point_name: str, **kwargs: Any - ) -> "_models.DiskRestorePoint": + ) -> _models.DiskRestorePoint: """Get disk restorePoint resource. :param resource_group_name: The name of the resource group. @@ -73,13 +72,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_02.models.DiskRestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePoint] request = build_get_request( @@ -90,11 +92,13 @@ async def get( disk_restore_point_name=disk_restore_point_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -122,7 +126,7 @@ def list_by_restore_point( restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskRestorePointList"]: + ) -> AsyncIterable[_models.DiskRestorePointList]: """Lists diskRestorePoints under a vmRestorePoint. :param resource_group_name: The name of the resource group. @@ -140,13 +144,16 @@ def list_by_restore_point( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskRestorePointList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePointList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePointList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -157,9 +164,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=self.list_by_restore_point.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -170,9 +179,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -211,17 +222,20 @@ async def _grant_access_initial( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -235,11 +249,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -269,9 +285,9 @@ async def begin_grant_access( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a diskRestorePoint. :param resource_group_name: The name of the resource group. @@ -300,17 +316,20 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, @@ -319,20 +338,27 @@ async def begin_grant_access( 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('AccessUri', 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( @@ -353,13 +379,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_restore_point_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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -370,11 +399,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_restore_point_name=disk_restore_point_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -424,22 +455,27 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, disk_restore_point_name=disk_restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -449,8 +485,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disks_operations.py index a8e532d241b2..003939642cac 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DisksOperations: - """DisksOperations async operations. - - You 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.compute.v2022_03_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_02.aio.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -132,37 +136,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -179,17 +193,20 @@ async def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -201,11 +218,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -235,9 +254,9 @@ async def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Disk"]: + ) -> AsyncLROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -260,37 +279,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -309,7 +338,7 @@ async def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -323,13 +352,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_02.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -338,11 +370,13 @@ async def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -369,13 +403,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -384,11 +421,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -432,20 +471,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -455,8 +499,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -474,7 +524,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -485,13 +535,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_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,9 +553,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -511,9 +566,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -550,7 +607,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DiskList"]: + ) -> AsyncIterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -559,13 +616,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -573,9 +633,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -583,9 +645,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -622,17 +686,20 @@ async def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -644,11 +711,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -676,9 +745,9 @@ async def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -703,37 +772,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -752,13 +831,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -767,11 +849,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -815,20 +899,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -838,8 +927,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_snapshots_operations.py index 26e3abe96612..bdd41a9c0b7f 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/aio/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 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 @@ -16,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,42 +27,43 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SnapshotsOperations: - """SnapshotsOperations async operations. - - You 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.compute.v2022_03_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_02.aio.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -73,11 +75,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -107,9 +111,9 @@ async def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -133,37 +137,47 @@ async def begin_create_or_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -180,17 +194,20 @@ async def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -202,11 +219,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -236,9 +255,9 @@ async def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> AsyncLROPoller["_models.Snapshot"]: + ) -> AsyncLROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -262,37 +281,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -311,7 +340,7 @@ async def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -325,13 +354,16 @@ async def get( :rtype: ~azure.mgmt.compute.v2022_03_02.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -340,11 +372,13 @@ async def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -371,13 +405,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -386,11 +423,13 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -434,20 +473,25 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -457,8 +501,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -476,7 +526,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -487,13 +537,16 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_02.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -502,9 +555,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -513,9 +568,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -552,7 +609,7 @@ async def get_next(next_link=None): def list( self, **kwargs: Any - ) -> AsyncIterable["_models.SnapshotList"]: + ) -> AsyncIterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -561,13 +618,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_03_02.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -575,9 +635,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -585,9 +647,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -624,17 +688,20 @@ async def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -646,11 +713,13 @@ async def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -678,9 +747,9 @@ async def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> AsyncLROPoller["_models.AccessUri"]: + ) -> AsyncLROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -705,37 +774,47 @@ async def begin_grant_access( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = await self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -754,13 +833,16 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -769,11 +851,13 @@ async def _revoke_access_initial( # pylint: disable=inconsistent-return-stateme snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -817,20 +901,25 @@ async def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # 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._revoke_access_initial( + raw_result = await self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -840,8 +929,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/__init__.py index f9c942a01f0b..bbd7fd3ee53e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/__init__.py @@ -80,7 +80,9 @@ PublicNetworkAccess, SnapshotStorageAccountTypes, ) - +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__ = [ 'AccessUri', 'ApiError', @@ -153,3 +155,5 @@ 'PublicNetworkAccess', 'SnapshotStorageAccountTypes', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_compute_management_client_enums.py index 2f9a55d73f43..a257ced13dba 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_compute_management_client_enums.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_compute_management_client_enums.py @@ -7,24 +7,23 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" READ = "Read" WRITE = "Write" -class Architecture(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): """CPU architecture supported by an OS disk. """ X64 = "x64" ARM64 = "Arm64" -class CopyCompletionErrorReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CopyCompletionErrorReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the error code if the background copy of a resource created via the CopyStart operation fails. """ @@ -33,7 +32,7 @@ class CopyCompletionErrorReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enu #: created via CopyStart operation was in progress. COPY_SOURCE_NOT_FOUND = "CopySourceNotFound" -class DataAccessAuthMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DataAccessAuthMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Additional authentication requirements when exporting or uploading to a disk or snapshot. """ @@ -44,7 +43,7 @@ class DataAccessAuthMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: No additional authentication would be performed when accessing export/upload URL. NONE = "None" -class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskCreateOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible sources of a disk's creation. """ @@ -77,7 +76,7 @@ class DiskCreateOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: disk and upload using write token in both disk and VM guest state. UPLOAD_PREPARED_SECURE = "UploadPreparedSecure" -class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted resources @@ -89,7 +88,7 @@ class DiskEncryptionSetIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskEncryptionSetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -102,7 +101,7 @@ class DiskEncryptionSetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: Confidential VM supported disk and VM guest state would be encrypted with customer managed key. CONFIDENTIAL_VM_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVmEncryptedWithCustomerKey" -class DiskSecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskSecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the SecurityType of the VM. Applicable for OS disks only. """ @@ -118,7 +117,7 @@ class DiskSecurityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: managed key. CONFIDENTIAL_VM_DISK_ENCRYPTED_WITH_CUSTOMER_KEY = "ConfidentialVM_DiskEncryptedWithCustomerKey" -class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This enumerates the possible state of the disk. """ @@ -139,7 +138,7 @@ class DiskState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: A disk is created for upload and a write token has been issued for uploading to it. ACTIVE_UPLOAD = "ActiveUpload" -class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DiskStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ @@ -163,7 +162,7 @@ class DiskStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) #: workloads that consistently require low latency and high IOPS and throughput. PREMIUM_V2_LRS = "PremiumV2_LRS" -class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of key used to encrypt the data of the disk. """ @@ -177,20 +176,20 @@ class EncryptionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: the other key is Platform managed. ENCRYPTION_AT_REST_WITH_PLATFORM_AND_CUSTOMER_KEYS = "EncryptionAtRestWithPlatformAndCustomerKeys" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class HyperVGeneration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine. Applicable to OS disks only. """ V1 = "V1" V2 = "V2" -class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class NetworkAccessPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Policy for accessing the disk via network. """ @@ -201,14 +200,14 @@ class NetworkAccessPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: The disk cannot be exported. DENY_ALL = "DenyAll" -class OperatingSystemTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Operating System type. """ WINDOWS = "Windows" LINUX = "Linux" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -217,7 +216,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. """ @@ -225,7 +224,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Policy for controlling export on the disk. """ @@ -238,7 +237,7 @@ class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): #: trusted Azure VNET when NetworkAccessPolicy is set to AllowPrivate. DISABLED = "Disabled" -class SnapshotStorageAccountTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SnapshotStorageAccountTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. """ diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_models_py3.py index ba69205e4690..baf8b3138753 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/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 ._compute_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessUri(msrest.serialization.Model): @@ -71,8 +73,8 @@ class ApiError(msrest.serialization.Model): def __init__( self, *, - details: Optional[List["ApiErrorBase"]] = None, - innererror: Optional["InnerError"] = None, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, code: Optional[str] = None, target: Optional[str] = None, message: Optional[str] = None, @@ -143,7 +145,7 @@ class CopyCompletionError(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar error_code: Required. Indicates the error code if the background copy of a resource - created via the CopyStart operation fails. Possible values include: "CopySourceNotFound". + created via the CopyStart operation fails. Known values are: "CopySourceNotFound". :vartype error_code: str or ~azure.mgmt.compute.v2022_03_02.models.CopyCompletionErrorReason :ivar error_message: Required. Indicates the error message if the background copy of a resource created via the CopyStart operation fails. @@ -163,13 +165,13 @@ class CopyCompletionError(msrest.serialization.Model): def __init__( self, *, - error_code: Union[str, "CopyCompletionErrorReason"], + error_code: Union[str, "_models.CopyCompletionErrorReason"], error_message: str, **kwargs ): """ :keyword error_code: Required. Indicates the error code if the background copy of a resource - created via the CopyStart operation fails. Possible values include: "CopySourceNotFound". + created via the CopyStart operation fails. Known values are: "CopySourceNotFound". :paramtype error_code: str or ~azure.mgmt.compute.v2022_03_02.models.CopyCompletionErrorReason :keyword error_message: Required. Indicates the error message if the background copy of a resource created via the CopyStart operation fails. @@ -187,9 +189,9 @@ class CreationData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", - "CopyStart", "ImportSecure", "UploadPreparedSecure". + :ivar create_option: Required. This enumerates the possible sources of a disk's creation. Known + values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart", + "ImportSecure", "UploadPreparedSecure". :vartype create_option: str or ~azure.mgmt.compute.v2022_03_02.models.DiskCreateOption :ivar storage_account_id: Required if createOption is Import. The Azure Resource Manager identifier of the storage account containing the blob to import as a disk. @@ -242,10 +244,10 @@ class CreationData(msrest.serialization.Model): def __init__( self, *, - create_option: Union[str, "DiskCreateOption"], + create_option: Union[str, "_models.DiskCreateOption"], storage_account_id: Optional[str] = None, - image_reference: Optional["ImageDiskReference"] = None, - gallery_image_reference: Optional["ImageDiskReference"] = None, + image_reference: Optional["_models.ImageDiskReference"] = None, + gallery_image_reference: Optional["_models.ImageDiskReference"] = None, source_uri: Optional[str] = None, source_resource_id: Optional[str] = None, upload_size_bytes: Optional[int] = None, @@ -255,7 +257,7 @@ def __init__( ): """ :keyword create_option: Required. This enumerates the possible sources of a disk's creation. - Possible values include: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", + Known values are: "Empty", "Attach", "FromImage", "Import", "Copy", "Restore", "Upload", "CopyStart", "ImportSecure", "UploadPreparedSecure". :paramtype create_option: str or ~azure.mgmt.compute.v2022_03_02.models.DiskCreateOption :keyword storage_account_id: Required if createOption is Import. The Azure Resource Manager @@ -385,10 +387,10 @@ class Disk(Resource): :vartype extended_location: ~azure.mgmt.compute.v2022_03_02.models.ExtendedLocation :ivar time_created: The time when the disk was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_02.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: @@ -429,7 +431,7 @@ class Disk(Resource): mounting the shared disk as ReadOnly. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10. :vartype disk_m_bps_read_only: long - :ivar disk_state: The state of the disk. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the disk. Known values are: "Unattached", "Attached", "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2022_03_02.models.DiskState :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed @@ -441,8 +443,8 @@ class Disk(Resource): :ivar share_info: Details of the list of all VMs that have the disk attached. maxShares should be set to a value greater than one for disks to allow attaching them to multiple VMs. :vartype share_info: list[~azure.mgmt.compute.v2022_03_02.models.ShareInfoElement] - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -464,12 +466,12 @@ class Disk(Resource): :ivar completion_percent: Percentage complete for the background copy when a resource is created via the CopyStart operation. :vartype completion_percent: float - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :vartype data_access_auth_mode: str or ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode """ @@ -537,31 +539,31 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, + sku: Optional["_models.DiskSku"] = None, zones: Optional[List[str]] = None, - extended_location: Optional["ExtendedLocation"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, - creation_data: Optional["CreationData"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, - encryption: Optional["Encryption"] = None, + encryption: Optional["_models.Encryption"] = None, max_shares: Optional[int] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, supports_hibernation: Optional[bool] = None, - security_profile: Optional["DiskSecurityProfile"] = None, + security_profile: Optional["_models.DiskSecurityProfile"] = None, completion_percent: Optional[float] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "DataAccessAuthMode"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, **kwargs ): """ @@ -577,10 +579,10 @@ def __init__( :keyword extended_location: The extended location where the disk will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2022_03_02.models.ExtendedLocation - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_02.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. E.g. - {name: 2019-Datacenter, publisher: MicrosoftWindowsServer, product: @@ -621,8 +623,8 @@ def __init__( :keyword max_shares: The maximum number of VMs that can attach to the disk at the same time. Value greater than one indicates a disk that can be mounted on multiple VMs at the same time. :paramtype max_shares: int - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -642,12 +644,12 @@ def __init__( :keyword completion_percent: Percentage complete for the background copy when a resource is created via the CopyStart operation. :paramtype completion_percent: float - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + uploading to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode """ @@ -745,7 +747,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, **kwargs ): """ @@ -788,7 +790,7 @@ class DiskAccessList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskAccess"], + value: List["_models.DiskAccess"], next_link: Optional[str] = None, **kwargs ): @@ -849,8 +851,8 @@ class DiskEncryptionSet(Resource): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2022_03_02.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", "ConfidentialVmEncryptedWithCustomerKey". :vartype encryption_type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetType :ivar active_key: The key vault key which is currently used by this disk encryption set. @@ -909,9 +911,9 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyForDiskEncryptionSet"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, rotation_to_latest_key_version_enabled: Optional[bool] = None, federated_client_id: Optional[str] = None, **kwargs @@ -924,8 +926,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2022_03_02.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", "ConfidentialVmEncryptedWithCustomerKey". :paramtype encryption_type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetType :keyword active_key: The key vault key which is currently used by this disk encryption set. @@ -973,7 +975,7 @@ class DiskEncryptionSetList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskEncryptionSet"], + value: List["_models.DiskEncryptionSet"], next_link: Optional[str] = None, **kwargs ): @@ -997,8 +999,8 @@ class DiskEncryptionSetUpdate(msrest.serialization.Model): :ivar identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :vartype identity: ~azure.mgmt.compute.v2022_03_02.models.EncryptionSetIdentity - :ivar encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", + :ivar encryption_type: The type of key used to encrypt the data of the disk. Known values are: + "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", "ConfidentialVmEncryptedWithCustomerKey". :vartype encryption_type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetType :ivar active_key: Key Vault Key Url to be used for server side encryption of Managed Disks and @@ -1025,9 +1027,9 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["EncryptionSetIdentity"] = None, - encryption_type: Optional[Union[str, "DiskEncryptionSetType"]] = None, - active_key: Optional["KeyForDiskEncryptionSet"] = None, + identity: Optional["_models.EncryptionSetIdentity"] = None, + encryption_type: Optional[Union[str, "_models.DiskEncryptionSetType"]] = None, + active_key: Optional["_models.KeyForDiskEncryptionSet"] = None, rotation_to_latest_key_version_enabled: Optional[bool] = None, federated_client_id: Optional[str] = None, **kwargs @@ -1038,8 +1040,8 @@ def __init__( :keyword identity: The managed identity for the disk encryption set. It should be given permission on the key vault before it can be used to encrypt disks. :paramtype identity: ~azure.mgmt.compute.v2022_03_02.models.EncryptionSetIdentity - :keyword encryption_type: The type of key used to encrypt the data of the disk. Possible values - include: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", + :keyword encryption_type: The type of key used to encrypt the data of the disk. Known values + are: "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys", "ConfidentialVmEncryptedWithCustomerKey". :paramtype encryption_type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetType :keyword active_key: Key Vault Key Url to be used for server side encryption of Managed Disks @@ -1085,7 +1087,7 @@ class DiskList(msrest.serialization.Model): def __init__( self, *, - value: List["Disk"], + value: List["_models.Disk"], next_link: Optional[str] = None, **kwargs ): @@ -1153,10 +1155,10 @@ class DiskRestorePoint(ProxyOnlyResource): :vartype time_created: ~datetime.datetime :ivar source_resource_id: arm id of source disk or source disk restore point. :vartype source_resource_id: str - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_02.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the the image from which the OS disk was created. @@ -1173,12 +1175,12 @@ class DiskRestorePoint(ProxyOnlyResource): :vartype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. :vartype supports_hibernation: bool - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -1236,20 +1238,20 @@ class DiskRestorePoint(ProxyOnlyResource): def __init__( self, *, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, supports_hibernation: Optional[bool] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, disk_access_id: Optional[str] = None, completion_percent: Optional[float] = None, - security_profile: Optional["DiskSecurityProfile"] = None, + security_profile: Optional["_models.DiskSecurityProfile"] = None, **kwargs ): """ :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_02.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the the image from which the OS disk was created. @@ -1259,12 +1261,12 @@ def __init__( :paramtype supported_capabilities: ~azure.mgmt.compute.v2022_03_02.models.SupportedCapabilities :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. :paramtype supports_hibernation: bool - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -1320,7 +1322,7 @@ class DiskRestorePointList(msrest.serialization.Model): def __init__( self, *, - value: List["DiskRestorePoint"], + value: List["_models.DiskRestorePoint"], next_link: Optional[str] = None, **kwargs ): @@ -1339,9 +1341,8 @@ def __init__( class DiskSecurityProfile(msrest.serialization.Model): """Contains the security related information for the resource. - :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Possible values include: "TrustedLaunch", - "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", + :ivar security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. Known + values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithCustomerKey". :vartype security_type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskSecurityTypes :ivar secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to @@ -1357,14 +1358,13 @@ class DiskSecurityProfile(msrest.serialization.Model): def __init__( self, *, - security_type: Optional[Union[str, "DiskSecurityTypes"]] = None, + security_type: Optional[Union[str, "_models.DiskSecurityTypes"]] = None, secure_vm_disk_encryption_set_id: Optional[str] = None, **kwargs ): """ :keyword security_type: Specifies the SecurityType of the VM. Applicable for OS disks only. - Possible values include: "TrustedLaunch", - "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", + Known values are: "TrustedLaunch", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithPlatformKey", "ConfidentialVM_DiskEncryptedWithCustomerKey". :paramtype security_type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskSecurityTypes :keyword secure_vm_disk_encryption_set_id: ResourceId of the disk encryption set associated to @@ -1381,8 +1381,8 @@ class DiskSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", + "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". :vartype name: str or ~azure.mgmt.compute.v2022_03_02.models.DiskStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -1400,11 +1400,11 @@ class DiskSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "DiskStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.DiskStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "StandardSSD_LRS", "UltraSSD_LRS", "Premium_ZRS", "StandardSSD_ZRS", "PremiumV2_LRS". :paramtype name: str or ~azure.mgmt.compute.v2022_03_02.models.DiskStorageAccountTypes """ @@ -1423,7 +1423,7 @@ class DiskUpdate(msrest.serialization.Model): :ivar sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. :vartype sku: ~azure.mgmt.compute.v2022_03_02.models.DiskSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1454,8 +1454,8 @@ class DiskUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -1476,12 +1476,12 @@ class DiskUpdate(msrest.serialization.Model): ~azure.mgmt.compute.v2022_03_02.models.PropertyUpdatesInProgress :ivar supports_hibernation: Indicates the OS on a disk supports hibernation. :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :vartype data_access_auth_mode: str or ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode """ @@ -1518,25 +1518,25 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["DiskSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.DiskSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, disk_iops_read_write: Optional[int] = None, disk_m_bps_read_write: Optional[int] = None, disk_iops_read_only: Optional[int] = None, disk_m_bps_read_only: Optional[int] = None, max_shares: Optional[int] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, tier: Optional[str] = None, bursting_enabled: Optional[bool] = None, - purchase_plan: Optional["PurchasePlan"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "DataAccessAuthMode"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, **kwargs ): """ @@ -1545,7 +1545,7 @@ def __init__( :keyword sku: The disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, UltraSSD_LRS, Premium_ZRS, StandardSSD_ZRS, or PremiumV2_LRS. :paramtype sku: ~azure.mgmt.compute.v2022_03_02.models.DiskSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -1576,8 +1576,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -1596,12 +1596,12 @@ def __init__( :paramtype supported_capabilities: ~azure.mgmt.compute.v2022_03_02.models.SupportedCapabilities :keyword supports_hibernation: Indicates the OS on a disk supports hibernation. :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + uploading to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode """ @@ -1635,7 +1635,7 @@ class Encryption(msrest.serialization.Model): :ivar disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :vartype disk_encryption_set_id: str - :ivar type: The type of key used to encrypt the data of the disk. Possible values include: + :ivar type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :vartype type: str or ~azure.mgmt.compute.v2022_03_02.models.EncryptionType @@ -1650,14 +1650,14 @@ def __init__( self, *, disk_encryption_set_id: Optional[str] = None, - type: Optional[Union[str, "EncryptionType"]] = None, + type: Optional[Union[str, "_models.EncryptionType"]] = None, **kwargs ): """ :keyword disk_encryption_set_id: ResourceId of the disk encryption set to use for enabling encryption at rest. :paramtype disk_encryption_set_id: str - :keyword type: The type of key used to encrypt the data of the disk. Possible values include: + :keyword type: The type of key used to encrypt the data of the disk. Known values are: "EncryptionAtRestWithPlatformKey", "EncryptionAtRestWithCustomerKey", "EncryptionAtRestWithPlatformAndCustomerKeys". :paramtype type: str or ~azure.mgmt.compute.v2022_03_02.models.EncryptionType @@ -1675,8 +1675,8 @@ class EncryptionSetIdentity(msrest.serialization.Model): :ivar type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the encrypted - resources to lose access to the keys. Possible values include: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". + resources to lose access to the keys. Known values are: "SystemAssigned", "UserAssigned", + "SystemAssigned, UserAssigned", "None". :vartype type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetIdentityType :ivar principal_id: The object id of the Managed Identity Resource. This will be sent to the RP from ARM via the x-ms-identity-principal-id header in the PUT request if the resource has a @@ -1708,15 +1708,15 @@ class EncryptionSetIdentity(msrest.serialization.Model): def __init__( self, *, - type: Optional[Union[str, "DiskEncryptionSetIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentitiesValue"]] = None, + type: Optional[Union[str, "_models.DiskEncryptionSetIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentitiesValue"]] = None, **kwargs ): """ :keyword type: The type of Managed Identity used by the DiskEncryptionSet. Only SystemAssigned is supported for new creations. Disk Encryption Sets can be updated with Identity type None during migration of subscription to a new Azure Active Directory tenant; it will cause the - encrypted resources to lose access to the keys. Possible values include: "SystemAssigned", + encrypted resources to lose access to the keys. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". :paramtype type: str or ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetIdentityType :keyword user_assigned_identities: The list of user identities associated with the disk @@ -1766,7 +1766,7 @@ def __init__( self, *, enabled: bool, - encryption_settings: Optional[List["EncryptionSettingsElement"]] = None, + encryption_settings: Optional[List["_models.EncryptionSettingsElement"]] = None, encryption_settings_version: Optional[str] = None, **kwargs ): @@ -1808,8 +1808,8 @@ class EncryptionSettingsElement(msrest.serialization.Model): def __init__( self, *, - disk_encryption_key: Optional["KeyVaultAndSecretReference"] = None, - key_encryption_key: Optional["KeyVaultAndKeyReference"] = None, + disk_encryption_key: Optional["_models.KeyVaultAndSecretReference"] = None, + key_encryption_key: Optional["_models.KeyVaultAndKeyReference"] = None, **kwargs ): """ @@ -1830,7 +1830,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.compute.v2022_03_02.models.ExtendedLocationTypes """ @@ -1843,13 +1843,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.compute.v2022_03_02.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -1862,7 +1862,7 @@ class GrantAccessData(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar access: Required. Possible values include: "None", "Read", "Write". + :ivar access: Required. Known values are: "None", "Read", "Write". :vartype access: str or ~azure.mgmt.compute.v2022_03_02.models.AccessLevel :ivar duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :vartype duration_in_seconds: int @@ -1885,13 +1885,13 @@ class GrantAccessData(msrest.serialization.Model): def __init__( self, *, - access: Union[str, "AccessLevel"], + access: Union[str, "_models.AccessLevel"], duration_in_seconds: int, get_secure_vm_guest_state_sas: Optional[bool] = None, **kwargs ): """ - :keyword access: Required. Possible values include: "None", "Read", "Write". + :keyword access: Required. Known values are: "None", "Read", "Write". :paramtype access: str or ~azure.mgmt.compute.v2022_03_02.models.AccessLevel :keyword duration_in_seconds: Required. Time duration in seconds until the SAS access expires. :paramtype duration_in_seconds: int @@ -2018,7 +2018,7 @@ def __init__( self, *, key_url: str, - source_vault: Optional["SourceVault"] = None, + source_vault: Optional["_models.SourceVault"] = None, **kwargs ): """ @@ -2059,7 +2059,7 @@ class KeyVaultAndKeyReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", key_url: str, **kwargs ): @@ -2098,7 +2098,7 @@ class KeyVaultAndSecretReference(msrest.serialization.Model): def __init__( self, *, - source_vault: "SourceVault", + source_vault: "_models.SourceVault", secret_url: str, **kwargs ): @@ -2158,7 +2158,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype private_link_service_connection_state: ~azure.mgmt.compute.v2022_03_02.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.compute.v2022_03_02.models.PrivateEndpointConnectionProvisioningState """ @@ -2183,7 +2183,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): def __init__( self, *, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -2219,7 +2219,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2304,7 +2304,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -2319,7 +2319,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.compute.v2022_03_02.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -2338,14 +2338,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, actions_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.compute.v2022_03_02.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -2592,10 +2592,10 @@ class Snapshot(Resource): :vartype extended_location: ~azure.mgmt.compute.v2022_03_02.models.ExtendedLocation :ivar time_created: The time when the snapshot was created. :vartype time_created: ~datetime.datetime - :ivar os_type: The Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: The Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :vartype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_02.models.HyperVGeneration :ivar purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. @@ -2613,7 +2613,7 @@ class Snapshot(Resource): :vartype disk_size_gb: int :ivar disk_size_bytes: The size of the disk in bytes. This field is read only. :vartype disk_size_bytes: long - :ivar disk_state: The state of the snapshot. Possible values include: "Unattached", "Attached", + :ivar disk_state: The state of the snapshot. Known values are: "Unattached", "Attached", "Reserved", "Frozen", "ActiveSAS", "ActiveSASFrozen", "ReadyToUpload", "ActiveUpload". :vartype disk_state: str or ~azure.mgmt.compute.v2022_03_02.models.DiskState :ivar unique_id: Unique Guid identifying the resource. @@ -2630,8 +2630,8 @@ class Snapshot(Resource): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. @@ -2640,8 +2640,8 @@ class Snapshot(Resource): :vartype security_profile: ~azure.mgmt.compute.v2022_03_02.models.DiskSecurityProfile :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess :ivar completion_percent: Percentage complete for the background copy when a resource is @@ -2651,7 +2651,7 @@ class Snapshot(Resource): created via the CopyStart operation fails. :vartype copy_completion_error: ~azure.mgmt.compute.v2022_03_02.models.CopyCompletionError :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :vartype data_access_auth_mode: str or ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode """ @@ -2707,25 +2707,25 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - extended_location: Optional["ExtendedLocation"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, - hyper_v_generation: Optional[Union[str, "HyperVGeneration"]] = None, - purchase_plan: Optional["PurchasePlan"] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, - creation_data: Optional["CreationData"] = None, + sku: Optional["_models.SnapshotSku"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + purchase_plan: Optional["_models.PurchasePlan"] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, + creation_data: Optional["_models.CreationData"] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, incremental: Optional[bool] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, - security_profile: Optional["DiskSecurityProfile"] = None, + security_profile: Optional["_models.DiskSecurityProfile"] = None, supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, completion_percent: Optional[float] = None, - copy_completion_error: Optional["CopyCompletionError"] = None, - data_access_auth_mode: Optional[Union[str, "DataAccessAuthMode"]] = None, + copy_completion_error: Optional["_models.CopyCompletionError"] = None, + data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, **kwargs ): """ @@ -2740,10 +2740,10 @@ def __init__( :keyword extended_location: The extended location where the snapshot will be created. Extended location cannot be changed. :paramtype extended_location: ~azure.mgmt.compute.v2022_03_02.models.ExtendedLocation - :keyword os_type: The Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: The Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine. Applicable to OS - disks only. Possible values include: "V1", "V2". + disks only. Known values are: "V1", "V2". :paramtype hyper_v_generation: str or ~azure.mgmt.compute.v2022_03_02.models.HyperVGeneration :keyword purchase_plan: Purchase plan information for the image from which the source disk for the snapshot was originally created. @@ -2769,8 +2769,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -2780,8 +2780,8 @@ def __init__( :paramtype security_profile: ~azure.mgmt.compute.v2022_03_02.models.DiskSecurityProfile :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess :keyword completion_percent: Percentage complete for the background copy when a resource is @@ -2791,7 +2791,7 @@ def __init__( resource created via the CopyStart operation fails. :paramtype copy_completion_error: ~azure.mgmt.compute.v2022_03_02.models.CopyCompletionError :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + uploading to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode """ @@ -2847,7 +2847,7 @@ class SnapshotList(msrest.serialization.Model): def __init__( self, *, - value: List["Snapshot"], + value: List["_models.Snapshot"], next_link: Optional[str] = None, **kwargs ): @@ -2868,8 +2868,7 @@ class SnapshotSku(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :ivar name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :vartype name: str or ~azure.mgmt.compute.v2022_03_02.models.SnapshotStorageAccountTypes :ivar tier: The sku tier. :vartype tier: str @@ -2887,12 +2886,11 @@ class SnapshotSku(msrest.serialization.Model): def __init__( self, *, - name: Optional[Union[str, "SnapshotStorageAccountTypes"]] = None, + name: Optional[Union[str, "_models.SnapshotStorageAccountTypes"]] = None, **kwargs ): """ - :keyword name: The sku name. Possible values include: "Standard_LRS", "Premium_LRS", - "Standard_ZRS". + :keyword name: The sku name. Known values are: "Standard_LRS", "Premium_LRS", "Standard_ZRS". :paramtype name: str or ~azure.mgmt.compute.v2022_03_02.models.SnapshotStorageAccountTypes """ super(SnapshotSku, self).__init__(**kwargs) @@ -2909,7 +2907,7 @@ class SnapshotUpdate(msrest.serialization.Model): an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. :vartype sku: ~azure.mgmt.compute.v2022_03_02.models.SnapshotSku - :ivar os_type: the Operating System type. Possible values include: "Windows", "Linux". + :ivar os_type: the Operating System type. Known values are: "Windows", "Linux". :vartype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes :ivar disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -2923,20 +2921,20 @@ class SnapshotUpdate(msrest.serialization.Model): :ivar encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :vartype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :ivar network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :ivar network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :vartype network_access_policy: str or ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy :ivar disk_access_id: ARM id of the DiskAccess resource for using private endpoints on disks. :vartype disk_access_id: str :ivar supports_hibernation: Indicates the OS on a snapshot supports hibernation. :vartype supports_hibernation: bool - :ivar public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :vartype public_network_access: str or ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess :ivar data_access_auth_mode: Additional authentication requirements when exporting or uploading - to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :vartype data_access_auth_mode: str or ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode :ivar supported_capabilities: List of supported capabilities for the image from which the OS @@ -2963,17 +2961,17 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - sku: Optional["SnapshotSku"] = None, - os_type: Optional[Union[str, "OperatingSystemTypes"]] = None, + sku: Optional["_models.SnapshotSku"] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, disk_size_gb: Optional[int] = None, - encryption_settings_collection: Optional["EncryptionSettingsCollection"] = None, - encryption: Optional["Encryption"] = None, - network_access_policy: Optional[Union[str, "NetworkAccessPolicy"]] = None, + encryption_settings_collection: Optional["_models.EncryptionSettingsCollection"] = None, + encryption: Optional["_models.Encryption"] = None, + network_access_policy: Optional[Union[str, "_models.NetworkAccessPolicy"]] = None, disk_access_id: Optional[str] = None, supports_hibernation: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - data_access_auth_mode: Optional[Union[str, "DataAccessAuthMode"]] = None, - supported_capabilities: Optional["SupportedCapabilities"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + data_access_auth_mode: Optional[Union[str, "_models.DataAccessAuthMode"]] = None, + supported_capabilities: Optional["_models.SupportedCapabilities"] = None, **kwargs ): """ @@ -2983,7 +2981,7 @@ def __init__( is an optional parameter for incremental snapshot and the default behavior is the SKU will be set to the same sku as the previous snapshot. :paramtype sku: ~azure.mgmt.compute.v2022_03_02.models.SnapshotSku - :keyword os_type: the Operating System type. Possible values include: "Windows", "Linux". + :keyword os_type: the Operating System type. Known values are: "Windows", "Linux". :paramtype os_type: str or ~azure.mgmt.compute.v2022_03_02.models.OperatingSystemTypes :keyword disk_size_gb: If creationData.createOption is Empty, this field is mandatory and it indicates the size of the disk to create. If this field is present for updates or creation with @@ -2997,8 +2995,8 @@ def __init__( :keyword encryption: Encryption property can be used to encrypt data at rest with customer managed keys or platform managed keys. :paramtype encryption: ~azure.mgmt.compute.v2022_03_02.models.Encryption - :keyword network_access_policy: Policy for accessing the disk via network. Possible values - include: "AllowAll", "AllowPrivate", "DenyAll". + :keyword network_access_policy: Policy for accessing the disk via network. Known values are: + "AllowAll", "AllowPrivate", "DenyAll". :paramtype network_access_policy: str or ~azure.mgmt.compute.v2022_03_02.models.NetworkAccessPolicy :keyword disk_access_id: ARM id of the DiskAccess resource for using private endpoints on @@ -3006,12 +3004,12 @@ def __init__( :paramtype disk_access_id: str :keyword supports_hibernation: Indicates the OS on a snapshot supports hibernation. :paramtype supports_hibernation: bool - :keyword public_network_access: Policy for controlling export on the disk. Possible values - include: "Enabled", "Disabled". + :keyword public_network_access: Policy for controlling export on the disk. Known values are: + "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.compute.v2022_03_02.models.PublicNetworkAccess :keyword data_access_auth_mode: Additional authentication requirements when exporting or - uploading to a disk or snapshot. Possible values include: "AzureActiveDirectory", "None". + uploading to a disk or snapshot. Known values are: "AzureActiveDirectory", "None". :paramtype data_access_auth_mode: str or ~azure.mgmt.compute.v2022_03_02.models.DataAccessAuthMode :keyword supported_capabilities: List of supported capabilities for the image from which the OS @@ -3116,8 +3114,7 @@ class SupportedCapabilities(msrest.serialization.Model): :ivar accelerated_network: True if the image from which the OS disk is created supports accelerated networking. :vartype accelerated_network: bool - :ivar architecture: CPU architecture supported by an OS disk. Possible values include: "x64", - "Arm64". + :ivar architecture: CPU architecture supported by an OS disk. Known values are: "x64", "Arm64". :vartype architecture: str or ~azure.mgmt.compute.v2022_03_02.models.Architecture """ @@ -3130,15 +3127,15 @@ def __init__( self, *, accelerated_network: Optional[bool] = None, - architecture: Optional[Union[str, "Architecture"]] = None, + architecture: Optional[Union[str, "_models.Architecture"]] = None, **kwargs ): """ :keyword accelerated_network: True if the image from which the OS disk is created supports accelerated networking. :paramtype accelerated_network: bool - :keyword architecture: CPU architecture supported by an OS disk. Possible values include: - "x64", "Arm64". + :keyword architecture: CPU architecture supported by an OS disk. Known values are: "x64", + "Arm64". :paramtype architecture: str or ~azure.mgmt.compute.v2022_03_02.models.Architecture """ super(SupportedCapabilities, self).__init__(**kwargs) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/__init__.py index 1c2791c4cde3..82801b1610e8 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/__init__.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/__init__.py @@ -12,6 +12,9 @@ from ._disk_restore_point_operations import DiskRestorePointOperations from ._snapshots_operations import SnapshotsOperations +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__ = [ 'DisksOperations', 'DiskAccessesOperations', @@ -19,3 +22,5 @@ 'DiskRestorePointOperations', 'SnapshotsOperations', ] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disk_accesses_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disk_accesses_operations.py index 0e46e9acdbaa..e71cd1b41de2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disk_accesses_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disk_accesses_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccess] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_access_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskAccessUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskAccesses") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_get_private_link_resources_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateLinkResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,18 +284,16 @@ def build_get_private_link_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -297,14 +304,17 @@ def build_update_a_private_endpoint_connection_request_initial( disk_access_name: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -317,20 +327,18 @@ def build_update_a_private_endpoint_connection_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -344,9 +352,12 @@ def build_get_a_private_endpoint_connection_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -359,18 +370,16 @@ def build_get_a_private_endpoint_connection_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -382,9 +391,12 @@ def build_delete_a_private_endpoint_connection_request_initial( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long path_format_arguments = { @@ -397,18 +409,16 @@ def build_delete_a_private_endpoint_connection_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -419,9 +429,12 @@ def build_list_private_endpoint_connections_request( disk_access_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskAccesses/{diskAccessName}/privateEndpointConnections") # pylint: disable=line-too-long path_format_arguments = { @@ -433,58 +446,57 @@ def build_list_private_endpoint_connections_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskAccessesOperations(object): - """DiskAccessesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskAccessesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_02.ComputeManagementClient`'s + :attr:`disk_accesses` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccess') @@ -496,11 +508,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -530,9 +544,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccess", + disk_access: _models.DiskAccess, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Creates or updates a disk access resource. :param resource_group_name: The name of the resource group. @@ -555,37 +569,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -602,17 +626,20 @@ def _update_initial( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> "_models.DiskAccess": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] + ) -> _models.DiskAccess: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] _json = self._serialize.body(disk_access, 'DiskAccessUpdate') @@ -624,11 +651,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -658,9 +687,9 @@ def begin_update( self, resource_group_name: str, disk_access_name: str, - disk_access: "_models.DiskAccessUpdate", + disk_access: _models.DiskAccessUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskAccess"]: + ) -> LROPoller[_models.DiskAccess]: """Updates (patches) a disk access resource. :param resource_group_name: The name of the resource group. @@ -683,37 +712,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskAccess] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, disk_access=disk_access, 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('DiskAccess', 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( @@ -732,7 +771,7 @@ def get( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.DiskAccess": + ) -> _models.DiskAccess: """Gets information about a disk access resource. :param resource_group_name: The name of the resource group. @@ -746,13 +785,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_02.models.DiskAccess :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccess"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccess] request = build_get_request( @@ -761,11 +803,13 @@ def get( disk_access_name=disk_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -792,13 +836,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -807,11 +854,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_access_name=disk_access_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -855,20 +904,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -878,8 +932,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -897,7 +957,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a resource group. :param resource_group_name: The name of the resource group. @@ -907,13 +967,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -922,9 +985,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -933,9 +998,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -972,7 +1039,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskAccessList"]: + ) -> Iterable[_models.DiskAccessList]: """Lists all the disk access resources under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -980,13 +1047,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskAccessList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskAccessList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskAccessList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -994,9 +1064,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1004,9 +1076,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1045,7 +1119,7 @@ def get_private_link_resources( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources possible under disk access resource. :param resource_group_name: The name of the resource group. @@ -1059,13 +1133,16 @@ def get_private_link_resources( :rtype: ~azure.mgmt.compute.v2022_03_02.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', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_get_private_link_resources_request( @@ -1074,11 +1151,13 @@ def get_private_link_resources( disk_access_name=disk_access_name, api_version=api_version, template_url=self.get_private_link_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1104,17 +1183,20 @@ def _update_a_private_endpoint_connection_initial( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: 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(private_endpoint_connection, 'PrivateEndpointConnection') @@ -1127,11 +1209,13 @@ def _update_a_private_endpoint_connection_initial( content_type=content_type, json=_json, template_url=self._update_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1162,9 +1246,9 @@ def begin_update_a_private_endpoint_connection( resource_group_name: str, disk_access_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection under disk access resource, this can't be used to create a new private endpoint connection. @@ -1194,17 +1278,20 @@ def begin_update_a_private_endpoint_connection( ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.PrivateEndpointConnection] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: 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] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_a_private_endpoint_connection_initial( + raw_result = self._update_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -1212,20 +1299,27 @@ def begin_update_a_private_endpoint_connection( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -1245,7 +1339,7 @@ def get_a_private_endpoint_connection( disk_access_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets information about a private endpoint connection under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1261,13 +1355,16 @@ def get_a_private_endpoint_connection( :rtype: ~azure.mgmt.compute.v2022_03_02.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', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_a_private_endpoint_connection_request( @@ -1277,11 +1374,13 @@ def get_a_private_endpoint_connection( private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self.get_a_private_endpoint_connection.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1309,13 +1408,16 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsiste private_endpoint_connection_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', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_a_private_endpoint_connection_request_initial( @@ -1325,11 +1427,13 @@ def _delete_a_private_endpoint_connection_initial( # pylint: disable=inconsiste private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, template_url=self._delete_a_private_endpoint_connection_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1376,21 +1480,26 @@ def begin_delete_a_private_endpoint_connection( # pylint: disable=inconsistent- :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_a_private_endpoint_connection_initial( + raw_result = self._delete_a_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, disk_access_name=disk_access_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1400,8 +1509,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -1420,7 +1535,7 @@ def list_private_endpoint_connections( resource_group_name: str, disk_access_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List information about private endpoint connections under a disk access resource. :param resource_group_name: The name of the resource group. @@ -1436,13 +1551,16 @@ def list_private_endpoint_connections( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_02.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] - 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: @@ -1452,9 +1570,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=self.list_private_endpoint_connections.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1464,9 +1584,11 @@ def prepare_request(next_link=None): disk_access_name=disk_access_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disk_encryption_sets_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disk_encryption_sets_operations.py index 0acfe99f2edc..ea6fea796535 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disk_encryption_sets_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disk_encryption_sets_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSet] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_encryption_set_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskEncryptionSetUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,9 +162,12 @@ def build_delete_request_initial( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}") # pylint: disable=line-too-long path_format_arguments = { @@ -173,18 +179,16 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) @@ -194,9 +198,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets") # pylint: disable=line-too-long path_format_arguments = { @@ -207,18 +214,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -227,9 +232,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/diskEncryptionSets") path_format_arguments = { @@ -239,18 +247,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -261,9 +267,12 @@ def build_list_associated_resources_request( disk_encryption_set_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}/associatedResources") # pylint: disable=line-too-long path_format_arguments = { @@ -275,58 +284,57 @@ def build_list_associated_resources_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class DiskEncryptionSetsOperations(object): - """DiskEncryptionSetsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskEncryptionSetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_02.ComputeManagementClient`'s + :attr:`disk_encryption_sets` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSet') @@ -338,11 +346,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -372,9 +382,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSet", + disk_encryption_set: _models.DiskEncryptionSet, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Creates or updates a disk encryption set. :param resource_group_name: The name of the resource group. @@ -399,37 +409,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -446,17 +466,20 @@ def _update_initial( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> "_models.DiskEncryptionSet": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] + ) -> _models.DiskEncryptionSet: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] _json = self._serialize.body(disk_encryption_set, 'DiskEncryptionSetUpdate') @@ -468,11 +491,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -502,9 +527,9 @@ def begin_update( self, resource_group_name: str, disk_encryption_set_name: str, - disk_encryption_set: "_models.DiskEncryptionSetUpdate", + disk_encryption_set: _models.DiskEncryptionSetUpdate, **kwargs: Any - ) -> LROPoller["_models.DiskEncryptionSet"]: + ) -> LROPoller[_models.DiskEncryptionSet]: """Updates (patches) a disk encryption set. :param resource_group_name: The name of the resource group. @@ -529,37 +554,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSet] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, disk_encryption_set=disk_encryption_set, 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('DiskEncryptionSet', 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( @@ -578,7 +613,7 @@ def get( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> "_models.DiskEncryptionSet": + ) -> _models.DiskEncryptionSet: """Gets information about a disk encryption set. :param resource_group_name: The name of the resource group. @@ -592,13 +627,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSet :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSet"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSet] request = build_get_request( @@ -607,11 +645,13 @@ def get( disk_encryption_set_name=disk_encryption_set_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -638,13 +678,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_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', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -653,11 +696,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -701,20 +746,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -724,8 +774,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -743,7 +799,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a resource group. :param resource_group_name: The name of the resource group. @@ -755,13 +811,16 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -770,9 +829,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -781,9 +842,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -820,7 +883,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskEncryptionSetList"]: + ) -> Iterable[_models.DiskEncryptionSetList]: """Lists all the disk encryption sets under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -830,13 +893,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskEncryptionSetList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskEncryptionSetList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskEncryptionSetList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -844,9 +910,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -854,9 +922,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -895,7 +965,7 @@ def list_associated_resources( resource_group_name: str, disk_encryption_set_name: str, **kwargs: Any - ) -> Iterable["_models.ResourceUriList"]: + ) -> Iterable[_models.ResourceUriList]: """Lists all resources that are encrypted with this disk encryption set. :param resource_group_name: The name of the resource group. @@ -909,13 +979,16 @@ def list_associated_resources( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_02.models.ResourceUriList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourceUriList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceUriList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -925,9 +998,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=self.list_associated_resources.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -937,9 +1012,11 @@ def prepare_request(next_link=None): disk_encryption_set_name=disk_encryption_set_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disk_restore_point_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disk_restore_point_operations.py index a4a95aade24b..b45e88a86d9e 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disk_restore_point_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disk_restore_point_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,9 +37,12 @@ def build_get_request( disk_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,18 +56,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -76,9 +77,12 @@ def build_list_by_restore_point_request( vm_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints") # pylint: disable=line-too-long path_format_arguments = { @@ -91,18 +95,16 @@ def build_list_by_restore_point_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -114,14 +116,17 @@ def build_grant_access_request_initial( vm_restore_point_name: str, disk_restore_point_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -135,20 +140,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -163,9 +166,12 @@ def build_revoke_access_request_initial( disk_restore_point_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -179,42 +185,38 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.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, + params=_params, + headers=_headers, **kwargs ) -class DiskRestorePointOperations(object): - """DiskRestorePointOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DiskRestorePointOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_02.ComputeManagementClient`'s + :attr:`disk_restore_point` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(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( @@ -224,7 +226,7 @@ def get( vm_restore_point_name: str, disk_restore_point_name: str, **kwargs: Any - ) -> "_models.DiskRestorePoint": + ) -> _models.DiskRestorePoint: """Get disk restorePoint resource. :param resource_group_name: The name of the resource group. @@ -242,13 +244,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_02.models.DiskRestorePoint :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePoint"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePoint] request = build_get_request( @@ -259,11 +264,13 @@ def get( disk_restore_point_name=disk_restore_point_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -291,7 +298,7 @@ def list_by_restore_point( restore_point_collection_name: str, vm_restore_point_name: str, **kwargs: Any - ) -> Iterable["_models.DiskRestorePointList"]: + ) -> Iterable[_models.DiskRestorePointList]: """Lists diskRestorePoints under a vmRestorePoint. :param resource_group_name: The name of the resource group. @@ -309,13 +316,16 @@ def list_by_restore_point( ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskRestorePointList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskRestorePointList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskRestorePointList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -326,9 +336,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=self.list_by_restore_point.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -339,9 +351,11 @@ def prepare_request(next_link=None): vm_restore_point_name=vm_restore_point_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(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,17 +394,20 @@ def _grant_access_initial( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -404,11 +421,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -438,9 +457,9 @@ def begin_grant_access( restore_point_collection_name: str, vm_restore_point_name: str, disk_restore_point_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a diskRestorePoint. :param resource_group_name: The name of the resource group. @@ -468,17 +487,20 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, @@ -487,20 +509,27 @@ def begin_grant_access( 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('AccessUri', 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( @@ -521,13 +550,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_restore_point_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', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -538,11 +570,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_restore_point_name=disk_restore_point_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -592,22 +626,27 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, restore_point_collection_name=restore_point_collection_name, vm_restore_point_name=vm_restore_point_name, disk_restore_point_name=disk_restore_point_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -617,8 +656,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disks_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disks_operations.py index aa76f41e96a1..0dd26bb321f2 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disks_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_disks_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.Disk] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.DiskUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, disk_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( disk_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class DisksOperations(object): - """DisksOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DisksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_02.ComputeManagementClient`'s + :attr:`disks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'Disk') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, disk_name: str, - disk: "_models.Disk", + disk: _models.Disk, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Creates or updates a disk. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> "_models.Disk": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] + ) -> _models.Disk: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] _json = self._serialize.body(disk, 'DiskUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, disk_name: str, - disk: "_models.DiskUpdate", + disk: _models.DiskUpdate, **kwargs: Any - ) -> LROPoller["_models.Disk"]: + ) -> LROPoller[_models.Disk]: """Updates (patches) a disk. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.Disk] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, disk=disk, 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('Disk', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, disk_name: str, **kwargs: Any - ) -> "_models.Disk": + ) -> _models.Disk: """Gets information about a disk. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_02.models.Disk :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Disk"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Disk] request = build_get_request( @@ -635,11 +672,13 @@ def get( disk_name=disk_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.DiskList"]: + ) -> Iterable[_models.DiskList]: """Lists all the disks under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_02.models.DiskList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DiskList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DiskList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, disk_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a disk. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_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', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements disk_name=disk_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, disk_name=disk_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_snapshots_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_snapshots_operations.py index 849c74c9a3e0..f08146810542 100644 --- a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_snapshots_operations.py +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_03_02/operations/_snapshots_operations.py @@ -6,7 +6,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +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 .. 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,14 +34,17 @@ def build_create_or_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.Snapshot] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -53,20 +56,18 @@ def build_create_or_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,14 +79,17 @@ def build_update_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.SnapshotUpdate] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -97,20 +101,18 @@ def build_update_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -123,9 +125,12 @@ def build_get_request( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -137,18 +142,16 @@ def build_get_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -159,8 +162,9 @@ def build_delete_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}") # pylint: disable=line-too-long path_format_arguments = { @@ -172,13 +176,12 @@ def build_delete_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) @@ -188,9 +191,12 @@ def build_list_by_resource_group_request( resource_group_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots") # pylint: disable=line-too-long path_format_arguments = { @@ -201,18 +207,16 @@ def build_list_by_resource_group_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -221,9 +225,12 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots") path_format_arguments = { @@ -233,18 +240,16 @@ def build_list_request( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -254,14 +259,17 @@ def build_grant_access_request_initial( resource_group_name: str, snapshot_name: str, *, - json: JSONType = None, + json: Optional[_models.GrantAccessData] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -273,20 +281,18 @@ def build_grant_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.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, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -299,8 +305,9 @@ def build_revoke_access_request_initial( snapshot_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess") # pylint: disable=line-too-long path_format_arguments = { @@ -312,53 +319,53 @@ def build_revoke_access_request_initial( _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: 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, + params=_params, **kwargs ) -class SnapshotsOperations(object): - """SnapshotsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SnapshotsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.compute.v2022_03_02.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_03_02.ComputeManagementClient`'s + :attr:`snapshots` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _create_or_update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'Snapshot') @@ -370,11 +377,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -404,9 +413,9 @@ def begin_create_or_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.Snapshot", + snapshot: _models.Snapshot, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Creates or updates a snapshot. :param resource_group_name: The name of the resource group. @@ -429,37 +438,47 @@ def begin_create_or_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -476,17 +495,20 @@ def _update_initial( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> "_models.Snapshot": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] + ) -> _models.Snapshot: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] _json = self._serialize.body(snapshot, 'SnapshotUpdate') @@ -498,11 +520,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -532,9 +556,9 @@ def begin_update( self, resource_group_name: str, snapshot_name: str, - snapshot: "_models.SnapshotUpdate", + snapshot: _models.SnapshotUpdate, **kwargs: Any - ) -> LROPoller["_models.Snapshot"]: + ) -> LROPoller[_models.Snapshot]: """Updates (patches) a snapshot. :param resource_group_name: The name of the resource group. @@ -557,37 +581,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.Snapshot] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, snapshot=snapshot, 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('Snapshot', 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( @@ -606,7 +640,7 @@ def get( resource_group_name: str, snapshot_name: str, **kwargs: Any - ) -> "_models.Snapshot": + ) -> _models.Snapshot: """Gets information about a snapshot. :param resource_group_name: The name of the resource group. @@ -620,13 +654,16 @@ def get( :rtype: ~azure.mgmt.compute.v2022_03_02.models.Snapshot :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Snapshot"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Snapshot] request = build_get_request( @@ -635,11 +672,13 @@ def get( snapshot_name=snapshot_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -666,13 +705,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_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 {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request_initial( @@ -681,11 +723,13 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -729,20 +773,25 @@ def begin_delete( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -752,8 +801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - 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( @@ -771,7 +826,7 @@ def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a resource group. :param resource_group_name: The name of the resource group. @@ -781,13 +836,16 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_02.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -796,9 +854,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, 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: @@ -807,9 +867,11 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -846,7 +908,7 @@ def get_next(next_link=None): def list( self, **kwargs: Any - ) -> Iterable["_models.SnapshotList"]: + ) -> Iterable[_models.SnapshotList]: """Lists snapshots under a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -854,13 +916,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_03_02.models.SnapshotList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.SnapshotList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SnapshotList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -868,9 +933,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -878,9 +945,11 @@ def prepare_request(next_link=None): subscription_id=self._config.subscription_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -917,17 +986,20 @@ def _grant_access_initial( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> Optional["_models.AccessUri"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.AccessUri"]] + ) -> Optional[_models.AccessUri]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # 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.AccessUri]] _json = self._serialize.body(grant_access_data, 'GrantAccessData') @@ -939,11 +1011,13 @@ def _grant_access_initial( content_type=content_type, json=_json, template_url=self._grant_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -971,9 +1045,9 @@ def begin_grant_access( self, resource_group_name: str, snapshot_name: str, - grant_access_data: "_models.GrantAccessData", + grant_access_data: _models.GrantAccessData, **kwargs: Any - ) -> LROPoller["_models.AccessUri"]: + ) -> LROPoller[_models.AccessUri]: """Grants access to a snapshot. :param resource_group_name: The name of the resource group. @@ -997,37 +1071,47 @@ def begin_grant_access( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_03_02.models.AccessUri] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AccessUri] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessUri"] 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._grant_access_initial( + raw_result = self._grant_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, grant_access_data=grant_access_data, 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('AccessUri', 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( @@ -1046,13 +1130,16 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_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', "2022-03-02") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_access_request_initial( @@ -1061,11 +1148,13 @@ def _revoke_access_initial( # pylint: disable=inconsistent-return-statements snapshot_name=snapshot_name, api_version=api_version, template_url=self._revoke_access_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( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -1109,20 +1198,25 @@ def begin_revoke_access( # pylint: disable=inconsistent-return-statements :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-02") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-02")) # 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._revoke_access_initial( + raw_result = self._revoke_access_initial( # type: ignore resource_group_name=resource_group_name, snapshot_name=snapshot_name, api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1132,8 +1226,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( diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/__init__.py new file mode 100644 index 000000000000..836b75d11272 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/__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 ._compute_management_client import ComputeManagementClient +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__ = ['ComputeManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_compute_management_client.py new file mode 100644 index 000000000000..c3cae24e4bee --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_compute_management_client.py @@ -0,0 +1,124 @@ +# 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 ComputeManagementClientConfiguration +from .operations import CloudServiceOperatingSystemsOperations, CloudServiceRoleInstancesOperations, CloudServiceRolesOperations, CloudServicesOperations, CloudServicesUpdateDomainOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class ComputeManagementClient: + """Compute Client. + + :ivar cloud_service_role_instances: CloudServiceRoleInstancesOperations operations + :vartype cloud_service_role_instances: + azure.mgmt.compute.v2022_04_04.operations.CloudServiceRoleInstancesOperations + :ivar cloud_service_roles: CloudServiceRolesOperations operations + :vartype cloud_service_roles: + azure.mgmt.compute.v2022_04_04.operations.CloudServiceRolesOperations + :ivar cloud_services: CloudServicesOperations operations + :vartype cloud_services: azure.mgmt.compute.v2022_04_04.operations.CloudServicesOperations + :ivar cloud_services_update_domain: CloudServicesUpdateDomainOperations operations + :vartype cloud_services_update_domain: + azure.mgmt.compute.v2022_04_04.operations.CloudServicesUpdateDomainOperations + :ivar cloud_service_operating_systems: CloudServiceOperatingSystemsOperations operations + :vartype cloud_service_operating_systems: + azure.mgmt.compute.v2022_04_04.operations.CloudServiceOperatingSystemsOperations + :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 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". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-04-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ComputeManagementClientConfiguration(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.cloud_service_role_instances = CloudServiceRoleInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_roles = CloudServiceRolesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services = CloudServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services_update_domain = CloudServicesUpdateDomainOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_operating_systems = CloudServiceOperatingSystemsOperations( + 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: () -> ComputeManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_configuration.py new file mode 100644 index 000000000000..67ebb6d74d3c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_configuration.py @@ -0,0 +1,74 @@ +# 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 ComputeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ComputeManagementClient. + + 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: Subscription credentials which uniquely identify 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 "2022-04-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ComputeManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-04-04") # 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-compute/{}'.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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_metadata.json b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_metadata.json new file mode 100644 index 000000000000..b54c11c057c6 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_metadata.json @@ -0,0 +1,106 @@ +{ + "chosen_version": "2022-04-04", + "total_api_version_list": ["2022-04-04"], + "client": { + "name": "ComputeManagementClient", + "filename": "_compute_management_client", + "description": "Compute Client.", + "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\": [\"ComputeManagementClientConfiguration\"]}, \"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\": [\"ComputeManagementClientConfiguration\"]}, \"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": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "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": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "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": { + "cloud_service_role_instances": "CloudServiceRoleInstancesOperations", + "cloud_service_roles": "CloudServiceRolesOperations", + "cloud_services": "CloudServicesOperations", + "cloud_services_update_domain": "CloudServicesUpdateDomainOperations", + "cloud_service_operating_systems": "CloudServiceOperatingSystemsOperations" + } +} \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_vendor.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_version.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/__init__.py new file mode 100644 index 000000000000..184d455419cc --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/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 ._compute_management_client import ComputeManagementClient + +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__ = ['ComputeManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/_compute_management_client.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/_compute_management_client.py new file mode 100644 index 000000000000..4679ccd9a17c --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/_compute_management_client.py @@ -0,0 +1,121 @@ +# 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 ComputeManagementClientConfiguration +from .operations import CloudServiceOperatingSystemsOperations, CloudServiceRoleInstancesOperations, CloudServiceRolesOperations, CloudServicesOperations, CloudServicesUpdateDomainOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class ComputeManagementClient: + """Compute Client. + + :ivar cloud_service_role_instances: CloudServiceRoleInstancesOperations operations + :vartype cloud_service_role_instances: + azure.mgmt.compute.v2022_04_04.aio.operations.CloudServiceRoleInstancesOperations + :ivar cloud_service_roles: CloudServiceRolesOperations operations + :vartype cloud_service_roles: + azure.mgmt.compute.v2022_04_04.aio.operations.CloudServiceRolesOperations + :ivar cloud_services: CloudServicesOperations operations + :vartype cloud_services: azure.mgmt.compute.v2022_04_04.aio.operations.CloudServicesOperations + :ivar cloud_services_update_domain: CloudServicesUpdateDomainOperations operations + :vartype cloud_services_update_domain: + azure.mgmt.compute.v2022_04_04.aio.operations.CloudServicesUpdateDomainOperations + :ivar cloud_service_operating_systems: CloudServiceOperatingSystemsOperations operations + :vartype cloud_service_operating_systems: + azure.mgmt.compute.v2022_04_04.aio.operations.CloudServiceOperatingSystemsOperations + :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 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". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-04-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = ComputeManagementClientConfiguration(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.cloud_service_role_instances = CloudServiceRoleInstancesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_roles = CloudServiceRolesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services = CloudServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_services_update_domain = CloudServicesUpdateDomainOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_service_operating_systems = CloudServiceOperatingSystemsOperations( + 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) -> "ComputeManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/_configuration.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/_configuration.py new file mode 100644 index 000000000000..e9d2ba5d8e8b --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/_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 ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class ComputeManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for ComputeManagementClient. + + 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: Subscription credentials which uniquely identify 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 "2022-04-04". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(ComputeManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-04-04") # 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-compute/{}'.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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/__init__.py new file mode 100644 index 000000000000..dbdb10f40f46 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/__init__.py @@ -0,0 +1,26 @@ +# 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 ._cloud_service_role_instances_operations import CloudServiceRoleInstancesOperations +from ._cloud_service_roles_operations import CloudServiceRolesOperations +from ._cloud_services_operations import CloudServicesOperations +from ._cloud_services_update_domain_operations import CloudServicesUpdateDomainOperations +from ._cloud_service_operating_systems_operations import CloudServiceOperatingSystemsOperations + +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__ = [ + 'CloudServiceRoleInstancesOperations', + 'CloudServiceRolesOperations', + 'CloudServicesOperations', + 'CloudServicesUpdateDomainOperations', + 'CloudServiceOperatingSystemsOperations', +] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_service_operating_systems_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_service_operating_systems_operations.py new file mode 100644 index 000000000000..8814aefc2689 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_service_operating_systems_operations.py @@ -0,0 +1,345 @@ +# 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._cloud_service_operating_systems_operations import build_get_os_family_request, build_get_os_version_request, build_list_os_families_request, build_list_os_versions_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CloudServiceOperatingSystemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_04_04.aio.ComputeManagementClient`'s + :attr:`cloud_service_operating_systems` 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_os_version( + self, + location: str, + os_version_name: str, + **kwargs: Any + ) -> _models.OSVersion: + """Gets properties of a guest operating system version that can be specified in the XML service + configuration (.cscfg) for a cloud service. + + :param location: Name of the location that the OS version pertains to. + :type location: str + :param os_version_name: Name of the OS version. + :type os_version_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OSVersion, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.OSVersion + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSVersion] + + + request = build_get_os_version_request( + location=location, + os_version_name=os_version_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_os_version.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('OSVersion', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_os_version.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions/{osVersionName}"} # type: ignore + + + @distributed_trace + def list_os_versions( + self, + location: str, + **kwargs: Any + ) -> AsyncIterable[_models.OSVersionListResult]: + """Gets a list of all guest operating system versions available to be specified in the XML service + configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the + next page of OS versions. Do this till nextLink is null to fetch all the OS versions. + + :param location: Name of the location that the OS versions pertain to. + :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 OSVersionListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_04_04.models.OSVersionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSVersionListResult] + + error_map = { + 401: ClientAuthenticationError, 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_os_versions_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_os_versions.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_os_versions_request( + location=location, + subscription_id=self._config.subscription_id, + 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("OSVersionListResult", 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_os_versions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions"} # type: ignore + + @distributed_trace_async + async def get_os_family( + self, + location: str, + os_family_name: str, + **kwargs: Any + ) -> _models.OSFamily: + """Gets properties of a guest operating system family that can be specified in the XML service + configuration (.cscfg) for a cloud service. + + :param location: Name of the location that the OS family pertains to. + :type location: str + :param os_family_name: Name of the OS family. + :type os_family_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OSFamily, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.OSFamily + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSFamily] + + + request = build_get_os_family_request( + location=location, + os_family_name=os_family_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_os_family.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('OSFamily', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_os_family.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies/{osFamilyName}"} # type: ignore + + + @distributed_trace + def list_os_families( + self, + location: str, + **kwargs: Any + ) -> AsyncIterable[_models.OSFamilyListResult]: + """Gets a list of all guest operating system families available to be specified in the XML service + configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the + next page of OS Families. Do this till nextLink is null to fetch all the OS Families. + + :param location: Name of the location that the OS families pertain to. + :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 OSFamilyListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_04_04.models.OSFamilyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSFamilyListResult] + + error_map = { + 401: ClientAuthenticationError, 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_os_families_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_os_families.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_os_families_request( + location=location, + subscription_id=self._config.subscription_id, + 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("OSFamilyListResult", 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_os_families.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_service_role_instances_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_service_role_instances_operations.py new file mode 100644 index 000000000000..c0c7f5c23fc6 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_service_role_instances_operations.py @@ -0,0 +1,859 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast + +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._cloud_service_role_instances_operations import build_delete_request_initial, build_get_instance_view_request, build_get_remote_desktop_file_request, build_get_request, build_list_request, build_rebuild_request_initial, build_reimage_request_initial, build_restart_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CloudServiceRoleInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_04_04.aio.ComputeManagementClient`'s + :attr:`cloud_service_role_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a role instance from a cloud service. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, + **kwargs: Any + ) -> _models.RoleInstance: + """Gets a role instance from a cloud service. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param expand: The expand expression to apply to the operation. 'UserData' is not supported for + cloud services. Default value is None. + :type expand: str or ~azure.mgmt.compute.v2022_04_04.models.InstanceViewTypes + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleInstance, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.RoleInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstance] + + + request = build_get_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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) # 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('RoleInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}"} # type: ignore + + + @distributed_trace_async + async def get_instance_view( + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> _models.RoleInstanceView: + """Retrieves information about the run-time state of a role instance in a cloud service. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleInstanceView, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.RoleInstanceView + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstanceView] + + + request = build_get_instance_view_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_instance_view.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('RoleInstanceView', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_instance_view.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/instanceView"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + cloud_service_name: str, + expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, + **kwargs: Any + ) -> AsyncIterable[_models.RoleInstanceListResult]: + """Gets the list of all role instances in a cloud service. Use nextLink property in the response + to get the next page of role instances. Do this till nextLink is null to fetch all the role + instances. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param expand: The expand expression to apply to the operation. 'UserData' is not supported for + cloud services. Default value is None. + :type expand: str or ~azure.mgmt.compute.v2022_04_04.models.InstanceViewTypes + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_04_04.models.RoleInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 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, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("RoleInstanceListResult", 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.Compute/cloudServices/{cloudServiceName}/roleInstances"} # type: ignore + + async def _restart_initial( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_restart_request_initial( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._restart_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, {}) + + _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/restart"} # type: ignore + + + @distributed_trace_async + async def begin_restart( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """The Reboot Role Instance asynchronous operation requests a reboot of a role instance in the + cloud service. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # 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._restart_initial( # type: ignore + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/restart"} # type: ignore + + async def _reimage_initial( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_reimage_request_initial( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._reimage_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, {}) + + _reimage_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/reimage"} # type: ignore + + + @distributed_trace_async + async def begin_reimage( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """The Reimage Role Instance asynchronous operation reinstalls the operating system on instances + of web roles or worker roles. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # 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._reimage_initial( # type: ignore + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_reimage.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/reimage"} # type: ignore + + async def _rebuild_initial( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_rebuild_request_initial( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._rebuild_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, {}) + + _rebuild_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/rebuild"} # type: ignore + + + @distributed_trace_async + async def begin_rebuild( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """The Rebuild Role Instance asynchronous operation reinstalls the operating system on instances + of web roles or worker roles and initializes the storage resources that are used by them. If + you do not want to initialize storage resources, you can use Reimage Role Instance. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # 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._rebuild_initial( # type: ignore + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_rebuild.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/rebuild"} # type: ignore + + @distributed_trace_async + async def get_remote_desktop_file( + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> IO: + """Gets a remote desktop file for a role instance in a cloud service. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[IO] + + + request = build_get_remote_desktop_file_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_remote_desktop_file.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=True, + **kwargs + ) + response = 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 = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_remote_desktop_file.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/remoteDesktopFile"} # type: ignore + diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_service_roles_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_service_roles_operations.py new file mode 100644 index 000000000000..b5c6c361287d --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_service_roles_operations.py @@ -0,0 +1,203 @@ +# 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._cloud_service_roles_operations import build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CloudServiceRolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_04_04.aio.ComputeManagementClient`'s + :attr:`cloud_service_roles` 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, + role_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> _models.CloudServiceRole: + """Gets a role from a cloud service. + + :param role_name: Name of the role. + :type role_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CloudServiceRole, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceRole + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceRole] + + + request = build_get_request( + role_name=role_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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('CloudServiceRole', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles/{roleName}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.CloudServiceRoleListResult]: + """Gets a list of all roles in a cloud service. Use nextLink property in the response to get the + next page of roles. Do this till nextLink is null to fetch all the roles. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CloudServiceRoleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_04_04.models.CloudServiceRoleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceRoleListResult] + + error_map = { + 401: ClientAuthenticationError, 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, + cloud_service_name=cloud_service_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, + cloud_service_name=cloud_service_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("CloudServiceRoleListResult", 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.Compute/cloudServices/{cloudServiceName}/roles"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_services_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_services_operations.py new file mode 100644 index 000000000000..2789730bcf40 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_services_operations.py @@ -0,0 +1,1529 @@ +# 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._cloud_services_operations import build_create_or_update_request_initial, build_delete_instances_request_initial, build_delete_request_initial, build_get_instance_view_request, build_get_request, build_list_all_request, build_list_request, build_power_off_request_initial, build_rebuild_request_initial, build_reimage_request_initial, build_restart_request_initial, build_start_request_initial, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CloudServicesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_04_04.aio.ComputeManagementClient`'s + :attr:`cloud_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") + + + async def _create_or_update_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.CloudService] = None, + **kwargs: Any + ) -> _models.CloudService: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] + + if parameters is not None: + _json = self._serialize.body(parameters, 'CloudService') + else: + _json = None + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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('CloudService', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('CloudService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.CloudService] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.CloudService]: + """Create or update a cloud service. Please note some properties can be set only during cloud + service creation. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param parameters: The cloud service object. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.CloudService + :keyword callable cls: A custom type or function that will be passed the direct response + :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 CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_04_04.models.CloudService] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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('CloudService', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.CloudServiceUpdate] = None, + **kwargs: Any + ) -> _models.CloudService: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] + + if parameters is not None: + _json = self._serialize.body(parameters, 'CloudServiceUpdate') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CloudService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.CloudServiceUpdate] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.CloudService]: + """Update a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param parameters: The cloud service object. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :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 CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.compute.v2022_04_04.models.CloudService] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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('CloudService', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> _models.CloudService: + """Display information about a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CloudService, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.CloudService + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] + + + request = build_get_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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('CloudService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + + @distributed_trace_async + async def get_instance_view( + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> _models.CloudServiceInstanceView: + """Gets the status of a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CloudServiceInstanceView, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceInstanceView + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceInstanceView] + + + request = build_get_instance_view_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_instance_view.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('CloudServiceInstanceView', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_instance_view.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/instanceView"} # type: ignore + + + @distributed_trace + def list_all( + self, + **kwargs: Any + ) -> AsyncIterable[_models.CloudServiceListResult]: + """Gets a list of all cloud services in the subscription, regardless of the associated resource + group. Use nextLink property in the response to get the next page of Cloud Services. Do this + till nextLink is null to fetch all the Cloud Services. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CloudServiceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_04_04.models.CloudServiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceListResult] + + error_map = { + 401: ClientAuthenticationError, 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_all_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_all_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("CloudServiceListResult", 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_all.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/cloudServices"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.CloudServiceListResult]: + """Gets a list of all cloud services under a resource group. Use nextLink property in the response + to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud + Services. + + :param resource_group_name: Name of the resource group. + :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 CloudServiceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_04_04.models.CloudServiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceListResult] + + error_map = { + 401: ClientAuthenticationError, 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, + subscription_id=self._config.subscription_id, + api_version=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, + subscription_id=self._config.subscription_id, + 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("CloudServiceListResult", 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.Compute/cloudServices"} # type: ignore + + async def _start_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_start_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_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, {}) + + _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/start"} # type: ignore + + + @distributed_trace_async + async def begin_start( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Starts the cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # 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._start_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/start"} # type: ignore + + async def _power_off_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_power_off_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._power_off_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, {}) + + _power_off_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/poweroff"} # type: ignore + + + @distributed_trace_async + async def begin_power_off( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Power off the cloud service. Note that resources are still attached and you are getting charged + for the resources. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # 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._power_off_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_power_off.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/poweroff"} # type: ignore + + async def _restart_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + if parameters is not None: + _json = self._serialize.body(parameters, 'RoleInstances') + else: + _json = None + + request = build_restart_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._restart_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, {}) + + _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/restart"} # type: ignore + + + @distributed_trace_async + async def begin_restart( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts one or more role instances in a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.RoleInstances + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # 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] + 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._restart_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/restart"} # type: ignore + + async def _reimage_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + if parameters is not None: + _json = self._serialize.body(parameters, 'RoleInstances') + else: + _json = None + + request = build_reimage_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._reimage_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, {}) + + _reimage_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/reimage"} # type: ignore + + + @distributed_trace_async + async def begin_reimage( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Reimage asynchronous operation reinstalls the operating system on instances of web roles or + worker roles. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.RoleInstances + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # 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] + 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._reimage_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_reimage.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/reimage"} # type: ignore + + async def _rebuild_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + if parameters is not None: + _json = self._serialize.body(parameters, 'RoleInstances') + else: + _json = None + + request = build_rebuild_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._rebuild_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, {}) + + _rebuild_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/rebuild"} # type: ignore + + + @distributed_trace_async + async def begin_rebuild( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker + roles and initializes the storage resources that are used by them. If you do not want to + initialize storage resources, you can use Reimage Role Instances. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.RoleInstances + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # 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] + 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._rebuild_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_rebuild.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/rebuild"} # type: ignore + + async def _delete_instances_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + if parameters is not None: + _json = self._serialize.body(parameters, 'RoleInstances') + else: + _json = None + + request = build_delete_instances_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._delete_instances_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, {}) + + _delete_instances_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/delete"} # type: ignore + + + @distributed_trace_async + async def begin_delete_instances( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes role instances in a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.RoleInstances + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_instances_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_instances.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/delete"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_services_update_domain_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_services_update_domain_operations.py new file mode 100644 index 000000000000..34d3a906c619 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_cloud_services_update_domain_operations.py @@ -0,0 +1,350 @@ +# 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._cloud_services_update_domain_operations import build_get_update_domain_request, build_list_update_domains_request, build_walk_update_domain_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CloudServicesUpdateDomainOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_04_04.aio.ComputeManagementClient`'s + :attr:`cloud_services_update_domain` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _walk_update_domain_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + parameters: Optional[_models.UpdateDomain] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + if parameters is not None: + _json = self._serialize.body(parameters, 'UpdateDomain') + else: + _json = None + + request = build_walk_update_domain_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + update_domain=update_domain, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._walk_update_domain_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, {}) + + _walk_update_domain_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}"} # type: ignore + + + @distributed_trace_async + async def begin_walk_update_domain( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + parameters: Optional[_models.UpdateDomain] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the role instances in the specified update domain. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param update_domain: Specifies an integer value that identifies the update domain. Update + domains are identified with a zero-based index: the first update domain has an ID of 0, the + second has an ID of 1, and so on. + :type update_domain: int + :param parameters: The update domain object. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.UpdateDomain + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # 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] + 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._walk_update_domain_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + update_domain=update_domain, + 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): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_walk_update_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}"} # type: ignore + + @distributed_trace_async + async def get_update_domain( + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + **kwargs: Any + ) -> _models.UpdateDomain: + """Gets the specified update domain of a cloud service. Use nextLink property in the response to + get the next page of update domains. Do this till nextLink is null to fetch all the update + domains. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param update_domain: Specifies an integer value that identifies the update domain. Update + domains are identified with a zero-based index: the first update domain has an ID of 0, the + second has an ID of 1, and so on. + :type update_domain: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UpdateDomain, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.UpdateDomain + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateDomain] + + + request = build_get_update_domain_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + update_domain=update_domain, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_domain.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('UpdateDomain', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_update_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}"} # type: ignore + + + @distributed_trace + def list_update_domains( + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.UpdateDomainListResult]: + """Gets a list of all update domains in a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UpdateDomainListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2022_04_04.models.UpdateDomainListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateDomainListResult] + + error_map = { + 401: ClientAuthenticationError, 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_update_domains_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_update_domains.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_update_domains_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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("UpdateDomainListResult", 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_update_domains.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/__init__.py new file mode 100644 index 000000000000..b6e36ddac83e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/__init__.py @@ -0,0 +1,133 @@ +# 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 ApiError +from ._models_py3 import ApiErrorBase +from ._models_py3 import CloudService +from ._models_py3 import CloudServiceExtensionProfile +from ._models_py3 import CloudServiceExtensionProperties +from ._models_py3 import CloudServiceInstanceView +from ._models_py3 import CloudServiceListResult +from ._models_py3 import CloudServiceNetworkProfile +from ._models_py3 import CloudServiceOsProfile +from ._models_py3 import CloudServiceProperties +from ._models_py3 import CloudServiceRole +from ._models_py3 import CloudServiceRoleListResult +from ._models_py3 import CloudServiceRoleProfile +from ._models_py3 import CloudServiceRoleProfileProperties +from ._models_py3 import CloudServiceRoleProperties +from ._models_py3 import CloudServiceRoleSku +from ._models_py3 import CloudServiceUpdate +from ._models_py3 import CloudServiceVaultAndSecretReference +from ._models_py3 import CloudServiceVaultCertificate +from ._models_py3 import CloudServiceVaultSecretGroup +from ._models_py3 import ExtendedLocation +from ._models_py3 import Extension +from ._models_py3 import InnerError +from ._models_py3 import InstanceSku +from ._models_py3 import InstanceViewStatusesSummary +from ._models_py3 import LoadBalancerConfiguration +from ._models_py3 import LoadBalancerConfigurationProperties +from ._models_py3 import LoadBalancerFrontendIPConfiguration +from ._models_py3 import LoadBalancerFrontendIPConfigurationProperties +from ._models_py3 import OSFamily +from ._models_py3 import OSFamilyListResult +from ._models_py3 import OSFamilyProperties +from ._models_py3 import OSVersion +from ._models_py3 import OSVersionListResult +from ._models_py3 import OSVersionProperties +from ._models_py3 import OSVersionPropertiesBase +from ._models_py3 import Resource +from ._models_py3 import ResourceInstanceViewStatus +from ._models_py3 import ResourceWithOptionalLocation +from ._models_py3 import RoleInstance +from ._models_py3 import RoleInstanceListResult +from ._models_py3 import RoleInstanceNetworkProfile +from ._models_py3 import RoleInstanceProperties +from ._models_py3 import RoleInstanceView +from ._models_py3 import RoleInstances +from ._models_py3 import StatusCodeCount +from ._models_py3 import SubResource +from ._models_py3 import SubResourceReadOnly +from ._models_py3 import SystemData +from ._models_py3 import UpdateDomain +from ._models_py3 import UpdateDomainListResult +from ._models_py3 import UserAssignedIdentitiesValue + + +from ._compute_management_client_enums import ( + CloudServiceSlotType, + CloudServiceUpgradeMode, + ExtendedLocationTypes, + InstanceViewTypes, + StatusLevelTypes, +) +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__ = [ + 'ApiError', + 'ApiErrorBase', + 'CloudService', + 'CloudServiceExtensionProfile', + 'CloudServiceExtensionProperties', + 'CloudServiceInstanceView', + 'CloudServiceListResult', + 'CloudServiceNetworkProfile', + 'CloudServiceOsProfile', + 'CloudServiceProperties', + 'CloudServiceRole', + 'CloudServiceRoleListResult', + 'CloudServiceRoleProfile', + 'CloudServiceRoleProfileProperties', + 'CloudServiceRoleProperties', + 'CloudServiceRoleSku', + 'CloudServiceUpdate', + 'CloudServiceVaultAndSecretReference', + 'CloudServiceVaultCertificate', + 'CloudServiceVaultSecretGroup', + 'ExtendedLocation', + 'Extension', + 'InnerError', + 'InstanceSku', + 'InstanceViewStatusesSummary', + 'LoadBalancerConfiguration', + 'LoadBalancerConfigurationProperties', + 'LoadBalancerFrontendIPConfiguration', + 'LoadBalancerFrontendIPConfigurationProperties', + 'OSFamily', + 'OSFamilyListResult', + 'OSFamilyProperties', + 'OSVersion', + 'OSVersionListResult', + 'OSVersionProperties', + 'OSVersionPropertiesBase', + 'Resource', + 'ResourceInstanceViewStatus', + 'ResourceWithOptionalLocation', + 'RoleInstance', + 'RoleInstanceListResult', + 'RoleInstanceNetworkProfile', + 'RoleInstanceProperties', + 'RoleInstanceView', + 'RoleInstances', + 'StatusCodeCount', + 'SubResource', + 'SubResourceReadOnly', + 'SystemData', + 'UpdateDomain', + 'UpdateDomainListResult', + 'UserAssignedIdentitiesValue', + 'CloudServiceSlotType', + 'CloudServiceUpgradeMode', + 'ExtendedLocationTypes', + 'InstanceViewTypes', + 'StatusLevelTypes', +] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/_compute_management_client_enums.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/_compute_management_client_enums.py new file mode 100644 index 000000000000..cf54bf52e075 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/_compute_management_client_enums.py @@ -0,0 +1,55 @@ +# 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 CloudServiceSlotType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Slot type for the cloud service. + Possible values are :code:`
`:code:`
`\ **Production**\ :code:`
`:code:`
`\ + **Staging**\ :code:`
`:code:`
` + If not specified, the default value is Production. + """ + + PRODUCTION = "Production" + STAGING = "Staging" + +class CloudServiceUpgradeMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Update mode for the cloud service. Role instances are allocated to update domains when the + service is deployed. Updates can be initiated manually in each update domain or initiated + automatically in all update domains. + Possible Values are :code:`
`:code:`
`\ **Auto**\ :code:`
`:code:`
`\ + **Manual** :code:`
`:code:`
`\ **Simultaneous**\ :code:`
`:code:`
` + If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called + to apply the update. If set to Auto, the update is automatically applied to each update domain + in sequence. + """ + + AUTO = "Auto" + MANUAL = "Manual" + SIMULTANEOUS = "Simultaneous" + +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of extendedLocation. + """ + + EDGE_ZONE = "EdgeZone" + +class InstanceViewTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + INSTANCE_VIEW = "instanceView" + USER_DATA = "userData" + +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The level code. + """ + + INFO = "Info" + WARNING = "Warning" + ERROR = "Error" diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/_models_py3.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/_models_py3.py new file mode 100644 index 000000000000..d89fc7741e1e --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/_models_py3.py @@ -0,0 +1,2246 @@ +# 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, Dict, List, Optional, TYPE_CHECKING, Union + +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class ApiError(msrest.serialization.Model): + """Api error. + + :ivar details: The Api error details. + :vartype details: list[~azure.mgmt.compute.v2022_04_04.models.ApiErrorBase] + :ivar innererror: The Api inner error. + :vartype innererror: ~azure.mgmt.compute.v2022_04_04.models.InnerError + :ivar code: The error code. + :vartype code: str + :ivar target: The target of the particular error. + :vartype target: str + :ivar message: The error message. + :vartype message: str + """ + + _attribute_map = { + 'details': {'key': 'details', 'type': '[ApiErrorBase]'}, + 'innererror': {'key': 'innererror', 'type': 'InnerError'}, + 'code': {'key': 'code', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + details: Optional[List["_models.ApiErrorBase"]] = None, + innererror: Optional["_models.InnerError"] = None, + code: Optional[str] = None, + target: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword details: The Api error details. + :paramtype details: list[~azure.mgmt.compute.v2022_04_04.models.ApiErrorBase] + :keyword innererror: The Api inner error. + :paramtype innererror: ~azure.mgmt.compute.v2022_04_04.models.InnerError + :keyword code: The error code. + :paramtype code: str + :keyword target: The target of the particular error. + :paramtype target: str + :keyword message: The error message. + :paramtype message: str + """ + super(ApiError, self).__init__(**kwargs) + self.details = details + self.innererror = innererror + self.code = code + self.target = target + self.message = message + + +class ApiErrorBase(msrest.serialization.Model): + """Api error base. + + :ivar code: The error code. + :vartype code: str + :ivar target: The target of the particular error. + :vartype target: str + :ivar message: The error message. + :vartype message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + target: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword code: The error code. + :paramtype code: str + :keyword target: The target of the particular error. + :paramtype target: str + :keyword message: The error message. + :paramtype message: str + """ + super(ApiErrorBase, self).__init__(**kwargs) + self.code = code + self.target = target + self.message = message + + +class CloudService(msrest.serialization.Model): + """Describes the cloud service. + + 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: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar properties: Cloud service properties. + :vartype properties: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceProperties + :ivar system_data: The system meta data relating to this resource. + :vartype system_data: ~azure.mgmt.compute.v2022_04_04.models.SystemData + """ + + _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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'properties': {'key': 'properties', 'type': 'CloudServiceProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.CloudServiceProperties"] = None, + system_data: Optional["_models.SystemData"] = None, + **kwargs + ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword properties: Cloud service properties. + :paramtype properties: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceProperties + :keyword system_data: The system meta data relating to this resource. + :paramtype system_data: ~azure.mgmt.compute.v2022_04_04.models.SystemData + """ + super(CloudService, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + self.properties = properties + self.system_data = system_data + + +class CloudServiceExtensionProfile(msrest.serialization.Model): + """Describes a cloud service extension profile. + + :ivar extensions: List of extensions for the cloud service. + :vartype extensions: list[~azure.mgmt.compute.v2022_04_04.models.Extension] + """ + + _attribute_map = { + 'extensions': {'key': 'extensions', 'type': '[Extension]'}, + } + + def __init__( + self, + *, + extensions: Optional[List["_models.Extension"]] = None, + **kwargs + ): + """ + :keyword extensions: List of extensions for the cloud service. + :paramtype extensions: list[~azure.mgmt.compute.v2022_04_04.models.Extension] + """ + super(CloudServiceExtensionProfile, self).__init__(**kwargs) + self.extensions = extensions + + +class CloudServiceExtensionProperties(msrest.serialization.Model): + """Extension Properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar publisher: The name of the extension handler publisher. + :vartype publisher: str + :ivar type: Specifies the type of the extension. + :vartype type: str + :ivar type_handler_version: Specifies the version of the extension. Specifies the version of + the extension. If this element is not specified or an asterisk (*) is used as the value, the + latest version of the extension is used. If the value is specified with a major version number + and an asterisk as the minor version number (X.), the latest minor version of the specified + major version is selected. If a major version number and a minor version number are specified + (X.Y), the specific extension version is selected. If a version is specified, an auto-upgrade + is performed on the role instance. + :vartype type_handler_version: str + :ivar auto_upgrade_minor_version: Explicitly specify whether platform can automatically upgrade + typeHandlerVersion to higher minor versions when they become available. + :vartype auto_upgrade_minor_version: bool + :ivar settings: Public settings for the extension. For JSON extensions, this is the JSON + settings for the extension. For XML Extension (like RDP), this is the XML setting for the + extension. + :vartype settings: any + :ivar protected_settings: Protected settings for the extension which are encrypted before sent + to the role instance. + :vartype protected_settings: any + :ivar protected_settings_from_key_vault: Protected settings for the extension, referenced using + KeyVault which are encrypted before sent to the role instance. + :vartype protected_settings_from_key_vault: + ~azure.mgmt.compute.v2022_04_04.models.CloudServiceVaultAndSecretReference + :ivar force_update_tag: Tag to force apply the provided public and protected settings. + Changing the tag value allows for re-running the extension without changing any of the public + or protected settings. + If forceUpdateTag is not changed, updates to public or protected settings would still be + applied by the handler. + If neither forceUpdateTag nor any of public or protected settings change, extension would flow + to the role instance with the same sequence-number, and + it is up to handler implementation whether to re-run it or not. + :vartype force_update_tag: str + :ivar provisioning_state: The provisioning state, which only appears in the response. + :vartype provisioning_state: str + :ivar roles_applied_to: Optional list of roles to apply this extension. If property is not + specified or '*' is specified, extension is applied to all roles in the cloud service. + :vartype roles_applied_to: list[str] + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'publisher': {'key': 'publisher', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'type_handler_version': {'key': 'typeHandlerVersion', 'type': 'str'}, + 'auto_upgrade_minor_version': {'key': 'autoUpgradeMinorVersion', 'type': 'bool'}, + 'settings': {'key': 'settings', 'type': 'object'}, + 'protected_settings': {'key': 'protectedSettings', 'type': 'object'}, + 'protected_settings_from_key_vault': {'key': 'protectedSettingsFromKeyVault', 'type': 'CloudServiceVaultAndSecretReference'}, + 'force_update_tag': {'key': 'forceUpdateTag', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'roles_applied_to': {'key': 'rolesAppliedTo', 'type': '[str]'}, + } + + def __init__( + self, + *, + publisher: Optional[str] = None, + type: Optional[str] = None, + type_handler_version: Optional[str] = None, + auto_upgrade_minor_version: Optional[bool] = None, + settings: Optional[Any] = None, + protected_settings: Optional[Any] = None, + protected_settings_from_key_vault: Optional["_models.CloudServiceVaultAndSecretReference"] = None, + force_update_tag: Optional[str] = None, + roles_applied_to: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword publisher: The name of the extension handler publisher. + :paramtype publisher: str + :keyword type: Specifies the type of the extension. + :paramtype type: str + :keyword type_handler_version: Specifies the version of the extension. Specifies the version of + the extension. If this element is not specified or an asterisk (*) is used as the value, the + latest version of the extension is used. If the value is specified with a major version number + and an asterisk as the minor version number (X.), the latest minor version of the specified + major version is selected. If a major version number and a minor version number are specified + (X.Y), the specific extension version is selected. If a version is specified, an auto-upgrade + is performed on the role instance. + :paramtype type_handler_version: str + :keyword auto_upgrade_minor_version: Explicitly specify whether platform can automatically + upgrade typeHandlerVersion to higher minor versions when they become available. + :paramtype auto_upgrade_minor_version: bool + :keyword settings: Public settings for the extension. For JSON extensions, this is the JSON + settings for the extension. For XML Extension (like RDP), this is the XML setting for the + extension. + :paramtype settings: any + :keyword protected_settings: Protected settings for the extension which are encrypted before + sent to the role instance. + :paramtype protected_settings: any + :keyword protected_settings_from_key_vault: Protected settings for the extension, referenced + using KeyVault which are encrypted before sent to the role instance. + :paramtype protected_settings_from_key_vault: + ~azure.mgmt.compute.v2022_04_04.models.CloudServiceVaultAndSecretReference + :keyword force_update_tag: Tag to force apply the provided public and protected settings. + Changing the tag value allows for re-running the extension without changing any of the public + or protected settings. + If forceUpdateTag is not changed, updates to public or protected settings would still be + applied by the handler. + If neither forceUpdateTag nor any of public or protected settings change, extension would flow + to the role instance with the same sequence-number, and + it is up to handler implementation whether to re-run it or not. + :paramtype force_update_tag: str + :keyword roles_applied_to: Optional list of roles to apply this extension. If property is not + specified or '*' is specified, extension is applied to all roles in the cloud service. + :paramtype roles_applied_to: list[str] + """ + super(CloudServiceExtensionProperties, self).__init__(**kwargs) + self.publisher = publisher + self.type = type + self.type_handler_version = type_handler_version + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.settings = settings + self.protected_settings = protected_settings + self.protected_settings_from_key_vault = protected_settings_from_key_vault + self.force_update_tag = force_update_tag + self.provisioning_state = None + self.roles_applied_to = roles_applied_to + + +class CloudServiceInstanceView(msrest.serialization.Model): + """InstanceView of CloudService as a whole. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar role_instance: Instance view statuses. + :vartype role_instance: ~azure.mgmt.compute.v2022_04_04.models.InstanceViewStatusesSummary + :ivar sdk_version: The version of the SDK that was used to generate the package for the cloud + service. + :vartype sdk_version: str + :ivar private_ids: Specifies a list of unique identifiers generated internally for the cloud + service. :code:`
`:code:`
` NOTE: If you are using Azure Diagnostics extension, this + property can be used as 'DeploymentId' for querying details. + :vartype private_ids: list[str] + :ivar statuses: + :vartype statuses: list[~azure.mgmt.compute.v2022_04_04.models.ResourceInstanceViewStatus] + """ + + _validation = { + 'sdk_version': {'readonly': True}, + 'private_ids': {'readonly': True}, + 'statuses': {'readonly': True}, + } + + _attribute_map = { + 'role_instance': {'key': 'roleInstance', 'type': 'InstanceViewStatusesSummary'}, + 'sdk_version': {'key': 'sdkVersion', 'type': 'str'}, + 'private_ids': {'key': 'privateIds', 'type': '[str]'}, + 'statuses': {'key': 'statuses', 'type': '[ResourceInstanceViewStatus]'}, + } + + def __init__( + self, + *, + role_instance: Optional["_models.InstanceViewStatusesSummary"] = None, + **kwargs + ): + """ + :keyword role_instance: Instance view statuses. + :paramtype role_instance: ~azure.mgmt.compute.v2022_04_04.models.InstanceViewStatusesSummary + """ + super(CloudServiceInstanceView, self).__init__(**kwargs) + self.role_instance = role_instance + self.sdk_version = None + self.private_ids = None + self.statuses = None + + +class CloudServiceListResult(msrest.serialization.Model): + """The list operation result. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Required. The list of resources. + :vartype value: list[~azure.mgmt.compute.v2022_04_04.models.CloudService] + :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of + resources. Do this till nextLink is null to fetch all the resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CloudService]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["_models.CloudService"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Required. The list of resources. + :paramtype value: list[~azure.mgmt.compute.v2022_04_04.models.CloudService] + :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page + of resources. Do this till nextLink is null to fetch all the resources. + :paramtype next_link: str + """ + super(CloudServiceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CloudServiceNetworkProfile(msrest.serialization.Model): + """Network Profile for the cloud service. + + :ivar load_balancer_configurations: List of Load balancer configurations. Cloud service can + have up to two load balancer configurations, corresponding to a Public Load Balancer and an + Internal Load Balancer. + :vartype load_balancer_configurations: + list[~azure.mgmt.compute.v2022_04_04.models.LoadBalancerConfiguration] + :ivar slot_type: Slot type for the cloud service. + Possible values are :code:`
`:code:`
`\ **Production**\ :code:`
`:code:`
`\ **Staging**\ :code:`
`:code:`
` + If not specified, the default value is Production. Known values are: "Production", "Staging". + :vartype slot_type: str or ~azure.mgmt.compute.v2022_04_04.models.CloudServiceSlotType + :ivar swappable_cloud_service: The id reference of the cloud service containing the target IP + with which the subject cloud service can perform a swap. This property cannot be updated once + it is set. The swappable cloud service referred by this id must be present otherwise an error + will be thrown. + :vartype swappable_cloud_service: ~azure.mgmt.compute.v2022_04_04.models.SubResource + """ + + _attribute_map = { + 'load_balancer_configurations': {'key': 'loadBalancerConfigurations', 'type': '[LoadBalancerConfiguration]'}, + 'slot_type': {'key': 'slotType', 'type': 'str'}, + 'swappable_cloud_service': {'key': 'swappableCloudService', 'type': 'SubResource'}, + } + + def __init__( + self, + *, + load_balancer_configurations: Optional[List["_models.LoadBalancerConfiguration"]] = None, + slot_type: Optional[Union[str, "_models.CloudServiceSlotType"]] = None, + swappable_cloud_service: Optional["_models.SubResource"] = None, + **kwargs + ): + """ + :keyword load_balancer_configurations: List of Load balancer configurations. Cloud service can + have up to two load balancer configurations, corresponding to a Public Load Balancer and an + Internal Load Balancer. + :paramtype load_balancer_configurations: + list[~azure.mgmt.compute.v2022_04_04.models.LoadBalancerConfiguration] + :keyword slot_type: Slot type for the cloud service. + Possible values are :code:`
`:code:`
`\ **Production**\ :code:`
`:code:`
`\ **Staging**\ :code:`
`:code:`
` + If not specified, the default value is Production. Known values are: "Production", "Staging". + :paramtype slot_type: str or ~azure.mgmt.compute.v2022_04_04.models.CloudServiceSlotType + :keyword swappable_cloud_service: The id reference of the cloud service containing the target + IP with which the subject cloud service can perform a swap. This property cannot be updated + once it is set. The swappable cloud service referred by this id must be present otherwise an + error will be thrown. + :paramtype swappable_cloud_service: ~azure.mgmt.compute.v2022_04_04.models.SubResource + """ + super(CloudServiceNetworkProfile, self).__init__(**kwargs) + self.load_balancer_configurations = load_balancer_configurations + self.slot_type = slot_type + self.swappable_cloud_service = swappable_cloud_service + + +class CloudServiceOsProfile(msrest.serialization.Model): + """Describes the OS profile for the cloud service. + + :ivar secrets: Specifies set of certificates that should be installed onto the role instances. + :vartype secrets: list[~azure.mgmt.compute.v2022_04_04.models.CloudServiceVaultSecretGroup] + """ + + _attribute_map = { + 'secrets': {'key': 'secrets', 'type': '[CloudServiceVaultSecretGroup]'}, + } + + def __init__( + self, + *, + secrets: Optional[List["_models.CloudServiceVaultSecretGroup"]] = None, + **kwargs + ): + """ + :keyword secrets: Specifies set of certificates that should be installed onto the role + instances. + :paramtype secrets: list[~azure.mgmt.compute.v2022_04_04.models.CloudServiceVaultSecretGroup] + """ + super(CloudServiceOsProfile, self).__init__(**kwargs) + self.secrets = secrets + + +class CloudServiceProperties(msrest.serialization.Model): + """Cloud service properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar package_url: Specifies a URL that refers to the location of the service package in the + Blob service. The service package URL can be Shared Access Signature (SAS) URI from any storage + account. + This is a write-only property and is not returned in GET calls. + :vartype package_url: str + :ivar configuration: Specifies the XML service configuration (.cscfg) for the cloud service. + :vartype configuration: str + :ivar configuration_url: Specifies a URL that refers to the location of the service + configuration in the Blob service. The service package URL can be Shared Access Signature + (SAS) URI from any storage account. + This is a write-only property and is not returned in GET calls. + :vartype configuration_url: str + :ivar start_cloud_service: (Optional) Indicates whether to start the cloud service immediately + after it is created. The default value is ``true``. + If false, the service model is still deployed, but the code is not run immediately. Instead, + the service is PoweredOff until you call Start, at which time the service will be started. A + deployed service still incurs charges, even if it is poweredoff. + :vartype start_cloud_service: bool + :ivar allow_model_override: (Optional) Indicates whether the role sku properties + (roleProfile.roles.sku) specified in the model/template should override the role instance count + and vm size specified in the .cscfg and .csdef respectively. + The default value is ``false``. + :vartype allow_model_override: bool + :ivar upgrade_mode: Update mode for the cloud service. Role instances are allocated to update + domains when the service is deployed. Updates can be initiated manually in each update domain + or initiated automatically in all update domains. + Possible Values are :code:`
`:code:`
`\ **Auto**\ :code:`
`:code:`
`\ + **Manual** :code:`
`:code:`
`\ **Simultaneous**\ :code:`
`:code:`
` + If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called + to apply the update. If set to Auto, the update is automatically applied to each update domain + in sequence. Known values are: "Auto", "Manual", "Simultaneous". + :vartype upgrade_mode: str or ~azure.mgmt.compute.v2022_04_04.models.CloudServiceUpgradeMode + :ivar role_profile: Describes the role profile for the cloud service. + :vartype role_profile: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceRoleProfile + :ivar os_profile: Describes the OS profile for the cloud service. + :vartype os_profile: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceOsProfile + :ivar network_profile: Network Profile for the cloud service. + :vartype network_profile: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceNetworkProfile + :ivar extension_profile: Describes a cloud service extension profile. + :vartype extension_profile: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceExtensionProfile + :ivar provisioning_state: The provisioning state, which only appears in the response. + :vartype provisioning_state: str + :ivar unique_id: The unique identifier for the cloud service. + :vartype unique_id: str + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'unique_id': {'readonly': True}, + } + + _attribute_map = { + 'package_url': {'key': 'packageUrl', 'type': 'str'}, + 'configuration': {'key': 'configuration', 'type': 'str'}, + 'configuration_url': {'key': 'configurationUrl', 'type': 'str'}, + 'start_cloud_service': {'key': 'startCloudService', 'type': 'bool'}, + 'allow_model_override': {'key': 'allowModelOverride', 'type': 'bool'}, + 'upgrade_mode': {'key': 'upgradeMode', 'type': 'str'}, + 'role_profile': {'key': 'roleProfile', 'type': 'CloudServiceRoleProfile'}, + 'os_profile': {'key': 'osProfile', 'type': 'CloudServiceOsProfile'}, + 'network_profile': {'key': 'networkProfile', 'type': 'CloudServiceNetworkProfile'}, + 'extension_profile': {'key': 'extensionProfile', 'type': 'CloudServiceExtensionProfile'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'unique_id': {'key': 'uniqueId', 'type': 'str'}, + } + + def __init__( + self, + *, + package_url: Optional[str] = None, + configuration: Optional[str] = None, + configuration_url: Optional[str] = None, + start_cloud_service: Optional[bool] = None, + allow_model_override: Optional[bool] = None, + upgrade_mode: Optional[Union[str, "_models.CloudServiceUpgradeMode"]] = None, + role_profile: Optional["_models.CloudServiceRoleProfile"] = None, + os_profile: Optional["_models.CloudServiceOsProfile"] = None, + network_profile: Optional["_models.CloudServiceNetworkProfile"] = None, + extension_profile: Optional["_models.CloudServiceExtensionProfile"] = None, + **kwargs + ): + """ + :keyword package_url: Specifies a URL that refers to the location of the service package in the + Blob service. The service package URL can be Shared Access Signature (SAS) URI from any storage + account. + This is a write-only property and is not returned in GET calls. + :paramtype package_url: str + :keyword configuration: Specifies the XML service configuration (.cscfg) for the cloud service. + :paramtype configuration: str + :keyword configuration_url: Specifies a URL that refers to the location of the service + configuration in the Blob service. The service package URL can be Shared Access Signature + (SAS) URI from any storage account. + This is a write-only property and is not returned in GET calls. + :paramtype configuration_url: str + :keyword start_cloud_service: (Optional) Indicates whether to start the cloud service + immediately after it is created. The default value is ``true``. + If false, the service model is still deployed, but the code is not run immediately. Instead, + the service is PoweredOff until you call Start, at which time the service will be started. A + deployed service still incurs charges, even if it is poweredoff. + :paramtype start_cloud_service: bool + :keyword allow_model_override: (Optional) Indicates whether the role sku properties + (roleProfile.roles.sku) specified in the model/template should override the role instance count + and vm size specified in the .cscfg and .csdef respectively. + The default value is ``false``. + :paramtype allow_model_override: bool + :keyword upgrade_mode: Update mode for the cloud service. Role instances are allocated to + update domains when the service is deployed. Updates can be initiated manually in each update + domain or initiated automatically in all update domains. + Possible Values are :code:`
`:code:`
`\ **Auto**\ :code:`
`:code:`
`\ + **Manual** :code:`
`:code:`
`\ **Simultaneous**\ :code:`
`:code:`
` + If not specified, the default value is Auto. If set to Manual, PUT UpdateDomain must be called + to apply the update. If set to Auto, the update is automatically applied to each update domain + in sequence. Known values are: "Auto", "Manual", "Simultaneous". + :paramtype upgrade_mode: str or ~azure.mgmt.compute.v2022_04_04.models.CloudServiceUpgradeMode + :keyword role_profile: Describes the role profile for the cloud service. + :paramtype role_profile: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceRoleProfile + :keyword os_profile: Describes the OS profile for the cloud service. + :paramtype os_profile: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceOsProfile + :keyword network_profile: Network Profile for the cloud service. + :paramtype network_profile: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceNetworkProfile + :keyword extension_profile: Describes a cloud service extension profile. + :paramtype extension_profile: + ~azure.mgmt.compute.v2022_04_04.models.CloudServiceExtensionProfile + """ + super(CloudServiceProperties, self).__init__(**kwargs) + self.package_url = package_url + self.configuration = configuration + self.configuration_url = configuration_url + self.start_cloud_service = start_cloud_service + self.allow_model_override = allow_model_override + self.upgrade_mode = upgrade_mode + self.role_profile = role_profile + self.os_profile = os_profile + self.network_profile = network_profile + self.extension_profile = extension_profile + self.provisioning_state = None + self.unique_id = None + + +class CloudServiceRole(msrest.serialization.Model): + """Describes a role of the cloud service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar sku: Describes the cloud service role sku. + :vartype sku: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceRoleSku + :ivar properties: The cloud service role properties. + :vartype properties: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceRoleProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'CloudServiceRoleSku'}, + 'properties': {'key': 'properties', 'type': 'CloudServiceRoleProperties'}, + } + + def __init__( + self, + *, + sku: Optional["_models.CloudServiceRoleSku"] = None, + properties: Optional["_models.CloudServiceRoleProperties"] = None, + **kwargs + ): + """ + :keyword sku: Describes the cloud service role sku. + :paramtype sku: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceRoleSku + :keyword properties: The cloud service role properties. + :paramtype properties: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceRoleProperties + """ + super(CloudServiceRole, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = None + self.sku = sku + self.properties = properties + + +class CloudServiceRoleListResult(msrest.serialization.Model): + """The list operation result. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Required. The list of resources. + :vartype value: list[~azure.mgmt.compute.v2022_04_04.models.CloudServiceRole] + :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of + resources. Do this till nextLink is null to fetch all the resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CloudServiceRole]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["_models.CloudServiceRole"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Required. The list of resources. + :paramtype value: list[~azure.mgmt.compute.v2022_04_04.models.CloudServiceRole] + :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page + of resources. Do this till nextLink is null to fetch all the resources. + :paramtype next_link: str + """ + super(CloudServiceRoleListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class CloudServiceRoleProfile(msrest.serialization.Model): + """Describes the role profile for the cloud service. + + :ivar roles: List of roles for the cloud service. + :vartype roles: list[~azure.mgmt.compute.v2022_04_04.models.CloudServiceRoleProfileProperties] + """ + + _attribute_map = { + 'roles': {'key': 'roles', 'type': '[CloudServiceRoleProfileProperties]'}, + } + + def __init__( + self, + *, + roles: Optional[List["_models.CloudServiceRoleProfileProperties"]] = None, + **kwargs + ): + """ + :keyword roles: List of roles for the cloud service. + :paramtype roles: + list[~azure.mgmt.compute.v2022_04_04.models.CloudServiceRoleProfileProperties] + """ + super(CloudServiceRoleProfile, self).__init__(**kwargs) + self.roles = roles + + +class CloudServiceRoleProfileProperties(msrest.serialization.Model): + """Describes the role properties. + + :ivar name: Resource name. + :vartype name: str + :ivar sku: Describes the cloud service role sku. + :vartype sku: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceRoleSku + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'CloudServiceRoleSku'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + sku: Optional["_models.CloudServiceRoleSku"] = None, + **kwargs + ): + """ + :keyword name: Resource name. + :paramtype name: str + :keyword sku: Describes the cloud service role sku. + :paramtype sku: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceRoleSku + """ + super(CloudServiceRoleProfileProperties, self).__init__(**kwargs) + self.name = name + self.sku = sku + + +class CloudServiceRoleProperties(msrest.serialization.Model): + """The cloud service role properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar unique_id: Specifies the ID which uniquely identifies a cloud service role. + :vartype unique_id: str + """ + + _validation = { + 'unique_id': {'readonly': True}, + } + + _attribute_map = { + 'unique_id': {'key': 'uniqueId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(CloudServiceRoleProperties, self).__init__(**kwargs) + self.unique_id = None + + +class CloudServiceRoleSku(msrest.serialization.Model): + """Describes the cloud service role sku. + + :ivar name: The sku name. NOTE: If the new SKU is not supported on the hardware the cloud + service is currently on, you need to delete and recreate the cloud service or move back to the + old sku. + :vartype name: str + :ivar tier: Specifies the tier of the cloud service. Possible Values are :code:`
`:code:`
` **Standard** :code:`
`:code:`
` **Basic**. + :vartype tier: str + :ivar capacity: Specifies the number of role instances in the cloud service. + :vartype capacity: long + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'capacity': {'key': 'capacity', 'type': 'long'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + tier: Optional[str] = None, + capacity: Optional[int] = None, + **kwargs + ): + """ + :keyword name: The sku name. NOTE: If the new SKU is not supported on the hardware the cloud + service is currently on, you need to delete and recreate the cloud service or move back to the + old sku. + :paramtype name: str + :keyword tier: Specifies the tier of the cloud service. Possible Values are :code:`
`:code:`
` **Standard** :code:`
`:code:`
` **Basic**. + :paramtype tier: str + :keyword capacity: Specifies the number of role instances in the cloud service. + :paramtype capacity: long + """ + super(CloudServiceRoleSku, self).__init__(**kwargs) + self.name = name + self.tier = tier + self.capacity = capacity + + +class CloudServiceUpdate(msrest.serialization.Model): + """CloudServiceUpdate. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(CloudServiceUpdate, self).__init__(**kwargs) + self.tags = tags + + +class CloudServiceVaultAndSecretReference(msrest.serialization.Model): + """Protected settings for the extension, referenced using KeyVault which are encrypted before sent to the role instance. + + :ivar source_vault: The ARM Resource ID of the Key Vault. + :vartype source_vault: ~azure.mgmt.compute.v2022_04_04.models.SubResource + :ivar secret_url: Secret URL which contains the protected settings of the extension. + :vartype secret_url: str + """ + + _attribute_map = { + 'source_vault': {'key': 'sourceVault', 'type': 'SubResource'}, + 'secret_url': {'key': 'secretUrl', 'type': 'str'}, + } + + def __init__( + self, + *, + source_vault: Optional["_models.SubResource"] = None, + secret_url: Optional[str] = None, + **kwargs + ): + """ + :keyword source_vault: The ARM Resource ID of the Key Vault. + :paramtype source_vault: ~azure.mgmt.compute.v2022_04_04.models.SubResource + :keyword secret_url: Secret URL which contains the protected settings of the extension. + :paramtype secret_url: str + """ + super(CloudServiceVaultAndSecretReference, self).__init__(**kwargs) + self.source_vault = source_vault + self.secret_url = secret_url + + +class CloudServiceVaultCertificate(msrest.serialization.Model): + """Describes a single certificate reference in a Key Vault, and where the certificate should reside on the role instance. + + :ivar certificate_url: This is the URL of a certificate that has been uploaded to Key Vault as + a secret. + :vartype certificate_url: str + """ + + _attribute_map = { + 'certificate_url': {'key': 'certificateUrl', 'type': 'str'}, + } + + def __init__( + self, + *, + certificate_url: Optional[str] = None, + **kwargs + ): + """ + :keyword certificate_url: This is the URL of a certificate that has been uploaded to Key Vault + as a secret. + :paramtype certificate_url: str + """ + super(CloudServiceVaultCertificate, self).__init__(**kwargs) + self.certificate_url = certificate_url + + +class CloudServiceVaultSecretGroup(msrest.serialization.Model): + """Describes a set of certificates which are all in the same Key Vault. + + :ivar source_vault: The relative URL of the Key Vault containing all of the certificates in + VaultCertificates. + :vartype source_vault: ~azure.mgmt.compute.v2022_04_04.models.SubResource + :ivar vault_certificates: The list of key vault references in SourceVault which contain + certificates. + :vartype vault_certificates: + list[~azure.mgmt.compute.v2022_04_04.models.CloudServiceVaultCertificate] + """ + + _attribute_map = { + 'source_vault': {'key': 'sourceVault', 'type': 'SubResource'}, + 'vault_certificates': {'key': 'vaultCertificates', 'type': '[CloudServiceVaultCertificate]'}, + } + + def __init__( + self, + *, + source_vault: Optional["_models.SubResource"] = None, + vault_certificates: Optional[List["_models.CloudServiceVaultCertificate"]] = None, + **kwargs + ): + """ + :keyword source_vault: The relative URL of the Key Vault containing all of the certificates in + VaultCertificates. + :paramtype source_vault: ~azure.mgmt.compute.v2022_04_04.models.SubResource + :keyword vault_certificates: The list of key vault references in SourceVault which contain + certificates. + :paramtype vault_certificates: + list[~azure.mgmt.compute.v2022_04_04.models.CloudServiceVaultCertificate] + """ + super(CloudServiceVaultSecretGroup, self).__init__(**kwargs) + self.source_vault = source_vault + self.vault_certificates = vault_certificates + + +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.compute.v2022_04_04.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.compute.v2022_04_04.models.ExtendedLocationTypes + """ + super(ExtendedLocation, self).__init__(**kwargs) + self.name = name + self.type = type + + +class Extension(msrest.serialization.Model): + """Describes a cloud service Extension. + + :ivar name: The name of the extension. + :vartype name: str + :ivar properties: Extension Properties. + :vartype properties: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceExtensionProperties + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'CloudServiceExtensionProperties'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.CloudServiceExtensionProperties"] = None, + **kwargs + ): + """ + :keyword name: The name of the extension. + :paramtype name: str + :keyword properties: Extension Properties. + :paramtype properties: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceExtensionProperties + """ + super(Extension, self).__init__(**kwargs) + self.name = name + self.properties = properties + + +class InnerError(msrest.serialization.Model): + """Inner error details. + + :ivar exceptiontype: The exception type. + :vartype exceptiontype: str + :ivar errordetail: The internal error message or exception dump. + :vartype errordetail: str + """ + + _attribute_map = { + 'exceptiontype': {'key': 'exceptiontype', 'type': 'str'}, + 'errordetail': {'key': 'errordetail', 'type': 'str'}, + } + + def __init__( + self, + *, + exceptiontype: Optional[str] = None, + errordetail: Optional[str] = None, + **kwargs + ): + """ + :keyword exceptiontype: The exception type. + :paramtype exceptiontype: str + :keyword errordetail: The internal error message or exception dump. + :paramtype errordetail: str + """ + super(InnerError, self).__init__(**kwargs) + self.exceptiontype = exceptiontype + self.errordetail = errordetail + + +class InstanceSku(msrest.serialization.Model): + """The role instance SKU. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The sku name. + :vartype name: str + :ivar tier: The tier of the cloud service role instance. + :vartype tier: str + """ + + _validation = { + 'name': {'readonly': True}, + 'tier': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(InstanceSku, self).__init__(**kwargs) + self.name = None + self.tier = None + + +class InstanceViewStatusesSummary(msrest.serialization.Model): + """Instance view statuses. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar statuses_summary: The summary. + :vartype statuses_summary: list[~azure.mgmt.compute.v2022_04_04.models.StatusCodeCount] + """ + + _validation = { + 'statuses_summary': {'readonly': True}, + } + + _attribute_map = { + 'statuses_summary': {'key': 'statusesSummary', 'type': '[StatusCodeCount]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(InstanceViewStatusesSummary, self).__init__(**kwargs) + self.statuses_summary = None + + +class LoadBalancerConfiguration(msrest.serialization.Model): + """Describes the load balancer configuration. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Required. The name of the Load balancer. + :vartype name: str + :ivar properties: Required. Properties of the load balancer configuration. + :vartype properties: ~azure.mgmt.compute.v2022_04_04.models.LoadBalancerConfigurationProperties + """ + + _validation = { + 'name': {'required': True}, + 'properties': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'LoadBalancerConfigurationProperties'}, + } + + def __init__( + self, + *, + name: str, + properties: "_models.LoadBalancerConfigurationProperties", + id: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Resource Id. + :paramtype id: str + :keyword name: Required. The name of the Load balancer. + :paramtype name: str + :keyword properties: Required. Properties of the load balancer configuration. + :paramtype properties: + ~azure.mgmt.compute.v2022_04_04.models.LoadBalancerConfigurationProperties + """ + super(LoadBalancerConfiguration, self).__init__(**kwargs) + self.id = id + self.name = name + self.properties = properties + + +class LoadBalancerConfigurationProperties(msrest.serialization.Model): + """Describes the properties of the load balancer configuration. + + All required parameters must be populated in order to send to Azure. + + :ivar frontend_ip_configurations: Required. Specifies the frontend IP to be used for the load + balancer. Only IPv4 frontend IP address is supported. Each load balancer configuration must + have exactly one frontend IP configuration. + :vartype frontend_ip_configurations: + list[~azure.mgmt.compute.v2022_04_04.models.LoadBalancerFrontendIPConfiguration] + """ + + _validation = { + 'frontend_ip_configurations': {'required': True}, + } + + _attribute_map = { + 'frontend_ip_configurations': {'key': 'frontendIPConfigurations', 'type': '[LoadBalancerFrontendIPConfiguration]'}, + } + + def __init__( + self, + *, + frontend_ip_configurations: List["_models.LoadBalancerFrontendIPConfiguration"], + **kwargs + ): + """ + :keyword frontend_ip_configurations: Required. Specifies the frontend IP to be used for the + load balancer. Only IPv4 frontend IP address is supported. Each load balancer configuration + must have exactly one frontend IP configuration. + :paramtype frontend_ip_configurations: + list[~azure.mgmt.compute.v2022_04_04.models.LoadBalancerFrontendIPConfiguration] + """ + super(LoadBalancerConfigurationProperties, self).__init__(**kwargs) + self.frontend_ip_configurations = frontend_ip_configurations + + +class LoadBalancerFrontendIPConfiguration(msrest.serialization.Model): + """Specifies the frontend IP to be used for the load balancer. Only IPv4 frontend IP address is supported. Each load balancer configuration must have exactly one frontend IP configuration. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The name of the resource that is unique within the set of frontend IP + configurations used by the load balancer. This name can be used to access the resource. + :vartype name: str + :ivar properties: Required. Properties of load balancer frontend ip configuration. + :vartype properties: + ~azure.mgmt.compute.v2022_04_04.models.LoadBalancerFrontendIPConfigurationProperties + """ + + _validation = { + 'name': {'required': True}, + 'properties': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'LoadBalancerFrontendIPConfigurationProperties'}, + } + + def __init__( + self, + *, + name: str, + properties: "_models.LoadBalancerFrontendIPConfigurationProperties", + **kwargs + ): + """ + :keyword name: Required. The name of the resource that is unique within the set of frontend IP + configurations used by the load balancer. This name can be used to access the resource. + :paramtype name: str + :keyword properties: Required. Properties of load balancer frontend ip configuration. + :paramtype properties: + ~azure.mgmt.compute.v2022_04_04.models.LoadBalancerFrontendIPConfigurationProperties + """ + super(LoadBalancerFrontendIPConfiguration, self).__init__(**kwargs) + self.name = name + self.properties = properties + + +class LoadBalancerFrontendIPConfigurationProperties(msrest.serialization.Model): + """Describes a cloud service IP Configuration. + + :ivar public_ip_address: The reference to the public ip address resource. + :vartype public_ip_address: ~azure.mgmt.compute.v2022_04_04.models.SubResource + :ivar subnet: The reference to the virtual network subnet resource. + :vartype subnet: ~azure.mgmt.compute.v2022_04_04.models.SubResource + :ivar private_ip_address: The virtual network private IP address of the IP configuration. + :vartype private_ip_address: str + """ + + _attribute_map = { + 'public_ip_address': {'key': 'publicIPAddress', 'type': 'SubResource'}, + 'subnet': {'key': 'subnet', 'type': 'SubResource'}, + 'private_ip_address': {'key': 'privateIPAddress', 'type': 'str'}, + } + + def __init__( + self, + *, + public_ip_address: Optional["_models.SubResource"] = None, + subnet: Optional["_models.SubResource"] = None, + private_ip_address: Optional[str] = None, + **kwargs + ): + """ + :keyword public_ip_address: The reference to the public ip address resource. + :paramtype public_ip_address: ~azure.mgmt.compute.v2022_04_04.models.SubResource + :keyword subnet: The reference to the virtual network subnet resource. + :paramtype subnet: ~azure.mgmt.compute.v2022_04_04.models.SubResource + :keyword private_ip_address: The virtual network private IP address of the IP configuration. + :paramtype private_ip_address: str + """ + super(LoadBalancerFrontendIPConfigurationProperties, self).__init__(**kwargs) + self.public_ip_address = public_ip_address + self.subnet = subnet + self.private_ip_address = private_ip_address + + +class OSFamily(msrest.serialization.Model): + """Describes a cloud service OS family. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar properties: OS family properties. + :vartype properties: ~azure.mgmt.compute.v2022_04_04.models.OSFamilyProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'OSFamilyProperties'}, + } + + def __init__( + self, + *, + properties: Optional["_models.OSFamilyProperties"] = None, + **kwargs + ): + """ + :keyword properties: OS family properties. + :paramtype properties: ~azure.mgmt.compute.v2022_04_04.models.OSFamilyProperties + """ + super(OSFamily, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = None + self.properties = properties + + +class OSFamilyListResult(msrest.serialization.Model): + """The list operation result. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Required. The list of resources. + :vartype value: list[~azure.mgmt.compute.v2022_04_04.models.OSFamily] + :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of + resources. Do this till nextLink is null to fetch all the resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OSFamily]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["_models.OSFamily"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Required. The list of resources. + :paramtype value: list[~azure.mgmt.compute.v2022_04_04.models.OSFamily] + :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page + of resources. Do this till nextLink is null to fetch all the resources. + :paramtype next_link: str + """ + super(OSFamilyListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OSFamilyProperties(msrest.serialization.Model): + """OS family properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The OS family name. + :vartype name: str + :ivar label: The OS family label. + :vartype label: str + :ivar versions: List of OS versions belonging to this family. + :vartype versions: list[~azure.mgmt.compute.v2022_04_04.models.OSVersionPropertiesBase] + """ + + _validation = { + 'name': {'readonly': True}, + 'label': {'readonly': True}, + 'versions': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'label': {'key': 'label', 'type': 'str'}, + 'versions': {'key': 'versions', 'type': '[OSVersionPropertiesBase]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OSFamilyProperties, self).__init__(**kwargs) + self.name = None + self.label = None + self.versions = None + + +class OSVersion(msrest.serialization.Model): + """Describes a cloud service OS version. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Resource location. + :vartype location: str + :ivar properties: OS version properties. + :vartype properties: ~azure.mgmt.compute.v2022_04_04.models.OSVersionProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'OSVersionProperties'}, + } + + def __init__( + self, + *, + properties: Optional["_models.OSVersionProperties"] = None, + **kwargs + ): + """ + :keyword properties: OS version properties. + :paramtype properties: ~azure.mgmt.compute.v2022_04_04.models.OSVersionProperties + """ + super(OSVersion, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = None + self.properties = properties + + +class OSVersionListResult(msrest.serialization.Model): + """The list operation result. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Required. The list of resources. + :vartype value: list[~azure.mgmt.compute.v2022_04_04.models.OSVersion] + :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of + resources. Do this till nextLink is null to fetch all the resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OSVersion]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["_models.OSVersion"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Required. The list of resources. + :paramtype value: list[~azure.mgmt.compute.v2022_04_04.models.OSVersion] + :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page + of resources. Do this till nextLink is null to fetch all the resources. + :paramtype next_link: str + """ + super(OSVersionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OSVersionProperties(msrest.serialization.Model): + """OS version properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar family: The family of this OS version. + :vartype family: str + :ivar family_label: The family label of this OS version. + :vartype family_label: str + :ivar version: The OS version. + :vartype version: str + :ivar label: The OS version label. + :vartype label: str + :ivar is_default: Specifies whether this is the default OS version for its family. + :vartype is_default: bool + :ivar is_active: Specifies whether this OS version is active. + :vartype is_active: bool + """ + + _validation = { + 'family': {'readonly': True}, + 'family_label': {'readonly': True}, + 'version': {'readonly': True}, + 'label': {'readonly': True}, + 'is_default': {'readonly': True}, + 'is_active': {'readonly': True}, + } + + _attribute_map = { + 'family': {'key': 'family', 'type': 'str'}, + 'family_label': {'key': 'familyLabel', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, + 'label': {'key': 'label', 'type': 'str'}, + 'is_default': {'key': 'isDefault', 'type': 'bool'}, + 'is_active': {'key': 'isActive', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OSVersionProperties, self).__init__(**kwargs) + self.family = None + self.family_label = None + self.version = None + self.label = None + self.is_default = None + self.is_active = None + + +class OSVersionPropertiesBase(msrest.serialization.Model): + """Configuration view of an OS version. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar version: The OS version. + :vartype version: str + :ivar label: The OS version label. + :vartype label: str + :ivar is_default: Specifies whether this is the default OS version for its family. + :vartype is_default: bool + :ivar is_active: Specifies whether this OS version is active. + :vartype is_active: bool + """ + + _validation = { + 'version': {'readonly': True}, + 'label': {'readonly': True}, + 'is_default': {'readonly': True}, + 'is_active': {'readonly': True}, + } + + _attribute_map = { + 'version': {'key': 'version', 'type': 'str'}, + 'label': {'key': 'label', 'type': 'str'}, + 'is_default': {'key': 'isDefault', 'type': 'bool'}, + 'is_active': {'key': 'isActive', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OSVersionPropertiesBase, self).__init__(**kwargs) + self.version = None + self.label = None + self.is_default = None + self.is_active = None + + +class Resource(msrest.serialization.Model): + """The Resource model definition. + + 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: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, 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'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class ResourceInstanceViewStatus(msrest.serialization.Model): + """Instance view status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The status code. + :vartype code: str + :ivar display_status: The short localizable label for the status. + :vartype display_status: str + :ivar message: The detailed status message, including for alerts and error messages. + :vartype message: str + :ivar time: The time of the status. + :vartype time: ~datetime.datetime + :ivar level: The level code. Known values are: "Info", "Warning", "Error". + :vartype level: str or ~azure.mgmt.compute.v2022_04_04.models.StatusLevelTypes + """ + + _validation = { + 'code': {'readonly': True}, + 'display_status': {'readonly': True}, + 'message': {'readonly': True}, + 'time': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'display_status': {'key': 'displayStatus', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'time': {'key': 'time', 'type': 'iso-8601'}, + 'level': {'key': 'level', 'type': 'str'}, + } + + def __init__( + self, + *, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, + **kwargs + ): + """ + :keyword level: The level code. Known values are: "Info", "Warning", "Error". + :paramtype level: str or ~azure.mgmt.compute.v2022_04_04.models.StatusLevelTypes + """ + super(ResourceInstanceViewStatus, self).__init__(**kwargs) + self.code = None + self.display_status = None + self.message = None + self.time = None + self.level = level + + +class ResourceWithOptionalLocation(msrest.serialization.Model): + """The Resource model definition with location property as optional. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: Resource location. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(ResourceWithOptionalLocation, self).__init__(**kwargs) + self.location = location + self.id = None + self.name = None + self.type = None + self.tags = tags + + +class RoleInstance(msrest.serialization.Model): + """Describes the cloud service role instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource Name. + :vartype name: str + :ivar type: Resource Type. + :vartype type: str + :ivar location: Resource Location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar sku: The role instance SKU. + :vartype sku: ~azure.mgmt.compute.v2022_04_04.models.InstanceSku + :ivar properties: Role instance properties. + :vartype properties: ~azure.mgmt.compute.v2022_04_04.models.RoleInstanceProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'readonly': True}, + 'tags': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'sku': {'key': 'sku', 'type': 'InstanceSku'}, + 'properties': {'key': 'properties', 'type': 'RoleInstanceProperties'}, + } + + def __init__( + self, + *, + sku: Optional["_models.InstanceSku"] = None, + properties: Optional["_models.RoleInstanceProperties"] = None, + **kwargs + ): + """ + :keyword sku: The role instance SKU. + :paramtype sku: ~azure.mgmt.compute.v2022_04_04.models.InstanceSku + :keyword properties: Role instance properties. + :paramtype properties: ~azure.mgmt.compute.v2022_04_04.models.RoleInstanceProperties + """ + super(RoleInstance, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = None + self.tags = None + self.sku = sku + self.properties = properties + + +class RoleInstanceListResult(msrest.serialization.Model): + """The list operation result. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Required. The list of resources. + :vartype value: list[~azure.mgmt.compute.v2022_04_04.models.RoleInstance] + :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of + resources. Do this till nextLink is null to fetch all the resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RoleInstance]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["_models.RoleInstance"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Required. The list of resources. + :paramtype value: list[~azure.mgmt.compute.v2022_04_04.models.RoleInstance] + :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page + of resources. Do this till nextLink is null to fetch all the resources. + :paramtype next_link: str + """ + super(RoleInstanceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleInstanceNetworkProfile(msrest.serialization.Model): + """Describes the network profile for the role instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar network_interfaces: Specifies the list of resource Ids for the network interfaces + associated with the role instance. + :vartype network_interfaces: list[~azure.mgmt.compute.v2022_04_04.models.SubResource] + """ + + _validation = { + 'network_interfaces': {'readonly': True}, + } + + _attribute_map = { + 'network_interfaces': {'key': 'networkInterfaces', 'type': '[SubResource]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(RoleInstanceNetworkProfile, self).__init__(**kwargs) + self.network_interfaces = None + + +class RoleInstanceProperties(msrest.serialization.Model): + """Role instance properties. + + :ivar network_profile: Describes the network profile for the role instance. + :vartype network_profile: ~azure.mgmt.compute.v2022_04_04.models.RoleInstanceNetworkProfile + :ivar instance_view: The instance view of the role instance. + :vartype instance_view: ~azure.mgmt.compute.v2022_04_04.models.RoleInstanceView + """ + + _attribute_map = { + 'network_profile': {'key': 'networkProfile', 'type': 'RoleInstanceNetworkProfile'}, + 'instance_view': {'key': 'instanceView', 'type': 'RoleInstanceView'}, + } + + def __init__( + self, + *, + network_profile: Optional["_models.RoleInstanceNetworkProfile"] = None, + instance_view: Optional["_models.RoleInstanceView"] = None, + **kwargs + ): + """ + :keyword network_profile: Describes the network profile for the role instance. + :paramtype network_profile: ~azure.mgmt.compute.v2022_04_04.models.RoleInstanceNetworkProfile + :keyword instance_view: The instance view of the role instance. + :paramtype instance_view: ~azure.mgmt.compute.v2022_04_04.models.RoleInstanceView + """ + super(RoleInstanceProperties, self).__init__(**kwargs) + self.network_profile = network_profile + self.instance_view = instance_view + + +class RoleInstances(msrest.serialization.Model): + """Specifies a list of role instances from the cloud service. + + All required parameters must be populated in order to send to Azure. + + :ivar role_instances: Required. List of cloud service role instance names. Value of '*' will + signify all role instances of the cloud service. + :vartype role_instances: list[str] + """ + + _validation = { + 'role_instances': {'required': True}, + } + + _attribute_map = { + 'role_instances': {'key': 'roleInstances', 'type': '[str]'}, + } + + def __init__( + self, + *, + role_instances: List[str], + **kwargs + ): + """ + :keyword role_instances: Required. List of cloud service role instance names. Value of '*' will + signify all role instances of the cloud service. + :paramtype role_instances: list[str] + """ + super(RoleInstances, self).__init__(**kwargs) + self.role_instances = role_instances + + +class RoleInstanceView(msrest.serialization.Model): + """The instance view of the role instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar platform_update_domain: The Update Domain. + :vartype platform_update_domain: int + :ivar platform_fault_domain: The Fault Domain. + :vartype platform_fault_domain: int + :ivar private_id: Specifies a unique identifier generated internally for the cloud service + associated with this role instance. :code:`
`:code:`
` NOTE: If you are using Azure + Diagnostics extension, this property can be used as 'DeploymentId' for querying details. + :vartype private_id: str + :ivar statuses: + :vartype statuses: list[~azure.mgmt.compute.v2022_04_04.models.ResourceInstanceViewStatus] + """ + + _validation = { + 'platform_update_domain': {'readonly': True}, + 'platform_fault_domain': {'readonly': True}, + 'private_id': {'readonly': True}, + 'statuses': {'readonly': True}, + } + + _attribute_map = { + 'platform_update_domain': {'key': 'platformUpdateDomain', 'type': 'int'}, + 'platform_fault_domain': {'key': 'platformFaultDomain', 'type': 'int'}, + 'private_id': {'key': 'privateId', 'type': 'str'}, + 'statuses': {'key': 'statuses', 'type': '[ResourceInstanceViewStatus]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(RoleInstanceView, self).__init__(**kwargs) + self.platform_update_domain = None + self.platform_fault_domain = None + self.private_id = None + self.statuses = None + + +class StatusCodeCount(msrest.serialization.Model): + """The status code and count of the cloud service instance view statuses. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The instance view status code. + :vartype code: str + :ivar count: Number of instances having this status code. + :vartype count: int + """ + + _validation = { + 'code': {'readonly': True}, + 'count': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'count': {'key': 'count', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(StatusCodeCount, self).__init__(**kwargs) + self.code = None + self.count = None + + +class SubResource(msrest.serialization.Model): + """SubResource. + + :ivar id: Resource Id. + :vartype id: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Resource Id. + :paramtype id: str + """ + super(SubResource, self).__init__(**kwargs) + self.id = id + + +class SubResourceReadOnly(msrest.serialization.Model): + """SubResourceReadOnly. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(SubResourceReadOnly, self).__init__(**kwargs) + self.id = None + + +class SystemData(msrest.serialization.Model): + """The system meta data relating to this resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar created_at: Specifies the time in UTC at which the Cloud Service (extended support) + resource was created. :code:`
`Minimum api-version: 2022-04-04. + :vartype created_at: ~datetime.datetime + :ivar last_modified_at: Specifies the time in UTC at which the Cloud Service (extended support) + resource was last modified. :code:`
`Minimum api-version: 2022-04-04. + :vartype last_modified_at: ~datetime.datetime + """ + + _validation = { + 'created_at': {'readonly': True}, + 'last_modified_at': {'readonly': True}, + } + + _attribute_map = { + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(SystemData, self).__init__(**kwargs) + self.created_at = None + self.last_modified_at = None + + +class UpdateDomain(msrest.serialization.Model): + """Defines an update domain for the cloud service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource Name. + :vartype name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UpdateDomain, self).__init__(**kwargs) + self.id = None + self.name = None + + +class UpdateDomainListResult(msrest.serialization.Model): + """The list operation result. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Required. The list of resources. + :vartype value: list[~azure.mgmt.compute.v2022_04_04.models.UpdateDomain] + :ivar next_link: The URI to fetch the next page of resources. Use this to get the next page of + resources. Do this till nextLink is null to fetch all the resources. + :vartype next_link: str + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[UpdateDomain]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: List["_models.UpdateDomain"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Required. The list of resources. + :paramtype value: list[~azure.mgmt.compute.v2022_04_04.models.UpdateDomain] + :keyword next_link: The URI to fetch the next page of resources. Use this to get the next page + of resources. Do this till nextLink is null to fetch all the resources. + :paramtype next_link: str + """ + super(UpdateDomainListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class UserAssignedIdentitiesValue(msrest.serialization.Model): + """UserAssignedIdentitiesValue. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned 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(UserAssignedIdentitiesValue, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/__init__.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/__init__.py new file mode 100644 index 000000000000..dbdb10f40f46 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/__init__.py @@ -0,0 +1,26 @@ +# 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 ._cloud_service_role_instances_operations import CloudServiceRoleInstancesOperations +from ._cloud_service_roles_operations import CloudServiceRolesOperations +from ._cloud_services_operations import CloudServicesOperations +from ._cloud_services_update_domain_operations import CloudServicesUpdateDomainOperations +from ._cloud_service_operating_systems_operations import CloudServiceOperatingSystemsOperations + +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__ = [ + 'CloudServiceRoleInstancesOperations', + 'CloudServiceRolesOperations', + 'CloudServicesOperations', + 'CloudServicesUpdateDomainOperations', + 'CloudServiceOperatingSystemsOperations', +] +__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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_service_operating_systems_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_service_operating_systems_operations.py new file mode 100644 index 000000000000..5accffba67e6 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_service_operating_systems_operations.py @@ -0,0 +1,490 @@ +# 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_get_os_version_request( + location: str, + os_version_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions/{osVersionName}") # pylint: disable=line-too-long + path_format_arguments = { + "location": _SERIALIZER.url("location", location, 'str'), + "osVersionName": _SERIALIZER.url("os_version_name", os_version_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_os_versions_request( + 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-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions") # pylint: disable=line-too-long + path_format_arguments = { + "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_os_family_request( + location: str, + os_family_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies/{osFamilyName}") # pylint: disable=line-too-long + path_format_arguments = { + "location": _SERIALIZER.url("location", location, 'str'), + "osFamilyName": _SERIALIZER.url("os_family_name", os_family_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_os_families_request( + 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-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies") # pylint: disable=line-too-long + path_format_arguments = { + "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class CloudServiceOperatingSystemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_04_04.ComputeManagementClient`'s + :attr:`cloud_service_operating_systems` 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_os_version( + self, + location: str, + os_version_name: str, + **kwargs: Any + ) -> _models.OSVersion: + """Gets properties of a guest operating system version that can be specified in the XML service + configuration (.cscfg) for a cloud service. + + :param location: Name of the location that the OS version pertains to. + :type location: str + :param os_version_name: Name of the OS version. + :type os_version_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OSVersion, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.OSVersion + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSVersion] + + + request = build_get_os_version_request( + location=location, + os_version_name=os_version_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_os_version.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('OSVersion', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_os_version.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions/{osVersionName}"} # type: ignore + + + @distributed_trace + def list_os_versions( + self, + location: str, + **kwargs: Any + ) -> Iterable[_models.OSVersionListResult]: + """Gets a list of all guest operating system versions available to be specified in the XML service + configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the + next page of OS versions. Do this till nextLink is null to fetch all the OS versions. + + :param location: Name of the location that the OS versions pertain to. + :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 OSVersionListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_04_04.models.OSVersionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSVersionListResult] + + error_map = { + 401: ClientAuthenticationError, 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_os_versions_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_os_versions.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_os_versions_request( + location=location, + subscription_id=self._config.subscription_id, + 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("OSVersionListResult", 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_os_versions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsVersions"} # type: ignore + + @distributed_trace + def get_os_family( + self, + location: str, + os_family_name: str, + **kwargs: Any + ) -> _models.OSFamily: + """Gets properties of a guest operating system family that can be specified in the XML service + configuration (.cscfg) for a cloud service. + + :param location: Name of the location that the OS family pertains to. + :type location: str + :param os_family_name: Name of the OS family. + :type os_family_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: OSFamily, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.OSFamily + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSFamily] + + + request = build_get_os_family_request( + location=location, + os_family_name=os_family_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_os_family.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('OSFamily', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_os_family.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies/{osFamilyName}"} # type: ignore + + + @distributed_trace + def list_os_families( + self, + location: str, + **kwargs: Any + ) -> Iterable[_models.OSFamilyListResult]: + """Gets a list of all guest operating system families available to be specified in the XML service + configuration (.cscfg) for a cloud service. Use nextLink property in the response to get the + next page of OS Families. Do this till nextLink is null to fetch all the OS Families. + + :param location: Name of the location that the OS families pertain to. + :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 OSFamilyListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_04_04.models.OSFamilyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OSFamilyListResult] + + error_map = { + 401: ClientAuthenticationError, 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_os_families_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_os_families.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_os_families_request( + location=location, + subscription_id=self._config.subscription_id, + 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("OSFamilyListResult", 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_os_families.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/cloudServiceOsFamilies"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_service_role_instances_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_service_role_instances_operations.py new file mode 100644 index 000000000000..1f023de69372 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_service_role_instances_operations.py @@ -0,0 +1,1179 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast + +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_delete_request_initial( + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}") # pylint: disable=line-too-long + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}") # pylint: disable=line-too-long + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + 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_get_instance_view_request( + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/instanceView") # pylint: disable=line-too-long + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + 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_restart_request_initial( + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/restart") # pylint: disable=line-too-long + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_reimage_request_initial( + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/reimage") # pylint: disable=line-too-long + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_rebuild_request_initial( + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/rebuild") # pylint: disable=line-too-long + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_remote_desktop_file_request( + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/x-rdp") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/remoteDesktopFile") # pylint: disable=line-too-long + path_format_arguments = { + "roleInstanceName": _SERIALIZER.url("role_instance_name", role_instance_name, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class CloudServiceRoleInstancesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_04_04.ComputeManagementClient`'s + :attr:`cloud_service_role_instances` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a role instance from a cloud service. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}"} # type: ignore + + @distributed_trace + def get( + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, + **kwargs: Any + ) -> _models.RoleInstance: + """Gets a role instance from a cloud service. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param expand: The expand expression to apply to the operation. 'UserData' is not supported for + cloud services. Default value is None. + :type expand: str or ~azure.mgmt.compute.v2022_04_04.models.InstanceViewTypes + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleInstance, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.RoleInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstance] + + + request = build_get_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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) # 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('RoleInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}"} # type: ignore + + + @distributed_trace + def get_instance_view( + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> _models.RoleInstanceView: + """Retrieves information about the run-time state of a role instance in a cloud service. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleInstanceView, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.RoleInstanceView + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstanceView] + + + request = build_get_instance_view_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_instance_view.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('RoleInstanceView', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_instance_view.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/instanceView"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + cloud_service_name: str, + expand: Optional[Union[str, "_models.InstanceViewTypes"]] = None, + **kwargs: Any + ) -> Iterable[_models.RoleInstanceListResult]: + """Gets the list of all role instances in a cloud service. Use nextLink property in the response + to get the next page of role instances. Do this till nextLink is null to fetch all the role + instances. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param expand: The expand expression to apply to the operation. 'UserData' is not supported for + cloud services. Default value is None. + :type expand: str or ~azure.mgmt.compute.v2022_04_04.models.InstanceViewTypes + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_04_04.models.RoleInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.RoleInstanceListResult] + + error_map = { + 401: ClientAuthenticationError, 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, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("RoleInstanceListResult", 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.Compute/cloudServices/{cloudServiceName}/roleInstances"} # type: ignore + + def _restart_initial( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_restart_request_initial( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._restart_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, {}) + + _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/restart"} # type: ignore + + + @distributed_trace + def begin_restart( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """The Reboot Role Instance asynchronous operation requests a reboot of a role instance in the + cloud service. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # 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._restart_initial( # type: ignore + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/restart"} # type: ignore + + def _reimage_initial( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_reimage_request_initial( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._reimage_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, {}) + + _reimage_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/reimage"} # type: ignore + + + @distributed_trace + def begin_reimage( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """The Reimage Role Instance asynchronous operation reinstalls the operating system on instances + of web roles or worker roles. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # 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._reimage_initial( # type: ignore + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_reimage.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/reimage"} # type: ignore + + def _rebuild_initial( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_rebuild_request_initial( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._rebuild_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, {}) + + _rebuild_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/rebuild"} # type: ignore + + + @distributed_trace + def begin_rebuild( # pylint: disable=inconsistent-return-statements + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """The Rebuild Role Instance asynchronous operation reinstalls the operating system on instances + of web roles or worker roles and initializes the storage resources that are used by them. If + you do not want to initialize storage resources, you can use Reimage Role Instance. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # 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._rebuild_initial( # type: ignore + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_rebuild.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/rebuild"} # type: ignore + + @distributed_trace + def get_remote_desktop_file( + self, + role_instance_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> IO: + """Gets a remote desktop file for a role instance in a cloud service. + + :param role_instance_name: Name of the role instance. + :type role_instance_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: IO, or the result of cls(response) + :rtype: IO + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[IO] + + + request = build_get_remote_desktop_file_request( + role_instance_name=role_instance_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_remote_desktop_file.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=True, + **kwargs + ) + response = 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 = response.stream_download(self._client._pipeline) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_remote_desktop_file.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/remoteDesktopFile"} # type: ignore + diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_service_roles_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_service_roles_operations.py new file mode 100644 index 000000000000..0b5a8a51c099 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_service_roles_operations.py @@ -0,0 +1,281 @@ +# 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_get_request( + role_name: str, + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles/{roleName}") # pylint: disable=line-too-long + path_format_arguments = { + "roleName": _SERIALIZER.url("role_name", role_name, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class CloudServiceRolesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_04_04.ComputeManagementClient`'s + :attr:`cloud_service_roles` 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, + role_name: str, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> _models.CloudServiceRole: + """Gets a role from a cloud service. + + :param role_name: Name of the role. + :type role_name: str + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CloudServiceRole, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceRole + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceRole] + + + request = build_get_request( + role_name=role_name, + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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('CloudServiceRole', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roles/{roleName}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> Iterable[_models.CloudServiceRoleListResult]: + """Gets a list of all roles in a cloud service. Use nextLink property in the response to get the + next page of roles. Do this till nextLink is null to fetch all the roles. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CloudServiceRoleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_04_04.models.CloudServiceRoleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceRoleListResult] + + error_map = { + 401: ClientAuthenticationError, 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, + cloud_service_name=cloud_service_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, + cloud_service_name=cloud_service_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("CloudServiceRoleListResult", 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.Compute/cloudServices/{cloudServiceName}/roles"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_services_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_services_operations.py new file mode 100644 index 000000000000..3efe51243a06 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_services_operations.py @@ -0,0 +1,2054 @@ +# 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_create_or_update_request_initial( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + *, + json: Optional[_models.CloudService] = 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-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + *, + json: Optional[_models.CloudServiceUpdate] = 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-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_instance_view_request( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/instanceView") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_all_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/cloudServices") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices") # 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) + + # 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_start_request_initial( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/start") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_power_off_request_initial( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/poweroff") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_restart_request_initial( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + *, + json: Optional[_models.RoleInstances] = 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-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/restart") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_reimage_request_initial( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + *, + json: Optional[_models.RoleInstances] = 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-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/reimage") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_rebuild_request_initial( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + *, + json: Optional[_models.RoleInstances] = 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-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/rebuild") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_instances_request_initial( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + *, + json: Optional[_models.RoleInstances] = 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-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/delete") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class CloudServicesOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_04_04.ComputeManagementClient`'s + :attr:`cloud_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") + + + def _create_or_update_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.CloudService] = None, + **kwargs: Any + ) -> _models.CloudService: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] + + if parameters is not None: + _json = self._serialize.body(parameters, 'CloudService') + else: + _json = None + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + 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('CloudService', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('CloudService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.CloudService] = None, + **kwargs: Any + ) -> LROPoller[_models.CloudService]: + """Create or update a cloud service. Please note some properties can be set only during cloud + service creation. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param parameters: The cloud service object. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.CloudService + :keyword callable cls: A custom type or function that will be passed the direct response + :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 CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_04_04.models.CloudService] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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('CloudService', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.CloudServiceUpdate] = None, + **kwargs: Any + ) -> _models.CloudService: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] + + if parameters is not None: + _json = self._serialize.body(parameters, 'CloudServiceUpdate') + else: + _json = None + + request = build_update_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CloudService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.CloudServiceUpdate] = None, + **kwargs: Any + ) -> LROPoller[_models.CloudService]: + """Update a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param parameters: The cloud service object. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :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 CloudService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.compute.v2022_04_04.models.CloudService] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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('CloudService', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + + @distributed_trace + def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> _models.CloudService: + """Display information about a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CloudService, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.CloudService + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudService] + + + request = build_get_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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('CloudService', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}"} # type: ignore + + + @distributed_trace + def get_instance_view( + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> _models.CloudServiceInstanceView: + """Gets the status of a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CloudServiceInstanceView, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.CloudServiceInstanceView + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceInstanceView] + + + request = build_get_instance_view_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_instance_view.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('CloudServiceInstanceView', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_instance_view.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/instanceView"} # type: ignore + + + @distributed_trace + def list_all( + self, + **kwargs: Any + ) -> Iterable[_models.CloudServiceListResult]: + """Gets a list of all cloud services in the subscription, regardless of the associated resource + group. Use nextLink property in the response to get the next page of Cloud Services. Do this + till nextLink is null to fetch all the Cloud Services. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either CloudServiceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_04_04.models.CloudServiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceListResult] + + error_map = { + 401: ClientAuthenticationError, 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_all_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_all_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("CloudServiceListResult", 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_all.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/cloudServices"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.CloudServiceListResult]: + """Gets a list of all cloud services under a resource group. Use nextLink property in the response + to get the next page of Cloud Services. Do this till nextLink is null to fetch all the Cloud + Services. + + :param resource_group_name: Name of the resource group. + :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 CloudServiceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_04_04.models.CloudServiceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CloudServiceListResult] + + error_map = { + 401: ClientAuthenticationError, 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, + subscription_id=self._config.subscription_id, + api_version=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, + subscription_id=self._config.subscription_id, + 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("CloudServiceListResult", 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.Compute/cloudServices"} # type: ignore + + def _start_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_start_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_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, {}) + + _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/start"} # type: ignore + + + @distributed_trace + def begin_start( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Starts the cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # 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._start_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/start"} # type: ignore + + def _power_off_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_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-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_power_off_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._power_off_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, {}) + + _power_off_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/poweroff"} # type: ignore + + + @distributed_trace + def begin_power_off( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Power off the cloud service. Note that resources are still attached and you are getting charged + for the resources. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_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-04-04")) # 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._power_off_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_power_off.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/poweroff"} # type: ignore + + def _restart_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + if parameters is not None: + _json = self._serialize.body(parameters, 'RoleInstances') + else: + _json = None + + request = build_restart_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._restart_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, {}) + + _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/restart"} # type: ignore + + + @distributed_trace + def begin_restart( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Restarts one or more role instances in a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.RoleInstances + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # 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] + 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._restart_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/restart"} # type: ignore + + def _reimage_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + if parameters is not None: + _json = self._serialize.body(parameters, 'RoleInstances') + else: + _json = None + + request = build_reimage_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._reimage_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, {}) + + _reimage_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/reimage"} # type: ignore + + + @distributed_trace + def begin_reimage( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Reimage asynchronous operation reinstalls the operating system on instances of web roles or + worker roles. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.RoleInstances + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # 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] + 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._reimage_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_reimage.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/reimage"} # type: ignore + + def _rebuild_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + if parameters is not None: + _json = self._serialize.body(parameters, 'RoleInstances') + else: + _json = None + + request = build_rebuild_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._rebuild_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, {}) + + _rebuild_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/rebuild"} # type: ignore + + + @distributed_trace + def begin_rebuild( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Rebuild Role Instances reinstalls the operating system on instances of web roles or worker + roles and initializes the storage resources that are used by them. If you do not want to + initialize storage resources, you can use Reimage Role Instances. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.RoleInstances + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # 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] + 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._rebuild_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_rebuild.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/rebuild"} # type: ignore + + def _delete_instances_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + if parameters is not None: + _json = self._serialize.body(parameters, 'RoleInstances') + else: + _json = None + + request = build_delete_instances_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._delete_instances_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, {}) + + _delete_instances_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/delete"} # type: ignore + + + @distributed_trace + def begin_delete_instances( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + parameters: Optional[_models.RoleInstances] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes role instances in a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param parameters: List of cloud service role instance names. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.RoleInstances + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # 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] + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_instances_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_instances.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/delete"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_services_update_domain_operations.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_services_update_domain_operations.py new file mode 100644 index 000000000000..d2c12ca818f9 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_cloud_services_update_domain_operations.py @@ -0,0 +1,475 @@ +# 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_walk_update_domain_request_initial( + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + subscription_id: str, + *, + json: Optional[_models.UpdateDomain] = 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-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "updateDomain": _SERIALIZER.url("update_domain", update_domain, 'int'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_update_domain_request( + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "updateDomain": _SERIALIZER.url("update_domain", update_domain, 'int'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_update_domains_request( + resource_group_name: str, + cloud_service_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "cloudServiceName": _SERIALIZER.url("cloud_service_name", cloud_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class CloudServicesUpdateDomainOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.compute.v2022_04_04.ComputeManagementClient`'s + :attr:`cloud_services_update_domain` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + def _walk_update_domain_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + parameters: Optional[_models.UpdateDomain] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + if parameters is not None: + _json = self._serialize.body(parameters, 'UpdateDomain') + else: + _json = None + + request = build_walk_update_domain_request_initial( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + update_domain=update_domain, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._walk_update_domain_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, {}) + + _walk_update_domain_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}"} # type: ignore + + + @distributed_trace + def begin_walk_update_domain( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + parameters: Optional[_models.UpdateDomain] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Updates the role instances in the specified update domain. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param update_domain: Specifies an integer value that identifies the update domain. Update + domains are identified with a zero-based index: the first update domain has an ID of 0, the + second has an ID of 1, and so on. + :type update_domain: int + :param parameters: The update domain object. Default value is None. + :type parameters: ~azure.mgmt.compute.v2022_04_04.models.UpdateDomain + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # 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] + 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._walk_update_domain_initial( # type: ignore + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + update_domain=update_domain, + 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): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_walk_update_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}"} # type: ignore + + @distributed_trace + def get_update_domain( + self, + resource_group_name: str, + cloud_service_name: str, + update_domain: int, + **kwargs: Any + ) -> _models.UpdateDomain: + """Gets the specified update domain of a cloud service. Use nextLink property in the response to + get the next page of update domains. Do this till nextLink is null to fetch all the update + domains. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :param update_domain: Specifies an integer value that identifies the update domain. Update + domains are identified with a zero-based index: the first update domain has an ID of 0, the + second has an ID of 1, and so on. + :type update_domain: int + :keyword callable cls: A custom type or function that will be passed the direct response + :return: UpdateDomain, or the result of cls(response) + :rtype: ~azure.mgmt.compute.v2022_04_04.models.UpdateDomain + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateDomain] + + + request = build_get_update_domain_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + update_domain=update_domain, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_update_domain.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('UpdateDomain', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_update_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}"} # type: ignore + + + @distributed_trace + def list_update_domains( + self, + resource_group_name: str, + cloud_service_name: str, + **kwargs: Any + ) -> Iterable[_models.UpdateDomainListResult]: + """Gets a list of all update domains in a cloud service. + + :param resource_group_name: Name of the resource group. + :type resource_group_name: str + :param cloud_service_name: Name of the cloud service. + :type cloud_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UpdateDomainListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.compute.v2022_04_04.models.UpdateDomainListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-04-04")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UpdateDomainListResult] + + error_map = { + 401: ClientAuthenticationError, 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_update_domains_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_update_domains.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_update_domains_request( + resource_group_name=resource_group_name, + cloud_service_name=cloud_service_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("UpdateDomainListResult", 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_update_domains.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains"} # type: ignore diff --git a/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_patch.py b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/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/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/py.typed b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2022_04_04/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file